1
Fork 0

Switch to GitHub Actions

This commit is contained in:
Jan-Erik Rediger 2021-01-05 20:41:11 +01:00
parent 4ca8284724
commit d4b1a24d07
8 changed files with 177 additions and 246 deletions

124
.github/workflows/deploy.yml vendored Normal file
View file

@ -0,0 +1,124 @@
# Based on https://github.com/starship/starship/blob/master/.github/workflows/deploy.yml
name: Deploy
on:
push:
tags:
- "*"
env:
CRATE_NAME: mdbook-toc
jobs:
# Build sources for every OS
github_build:
name: Build release binaries
strategy:
fail-fast: false
matrix:
target:
- x86_64-unknown-linux-gnu
- x86_64-unknown-linux-musl
- x86_64-apple-darwin
- x86_64-pc-windows-msvc
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
name: x86_64-unknown-linux-gnu.tar.gz
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
name: x86_64-unknown-linux-musl.tar.gz
- target: x86_64-apple-darwin
os: macOS-latest
name: x86_64-apple-darwin.tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
name: x86_64-pc-windows-msvc.zip
runs-on: ${{ matrix.os }}
steps:
- name: Setup | Checkout
uses: actions/checkout@v2
# Cache files between builds
- name: Setup | Cache Cargo
uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Setup | Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
override: true
profile: minimal
target: ${{ matrix.target }}
- name: Setup | musl tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt install -y musl-tools
- name: Build | Build
if: matrix.target != 'x86_64-unknown-linux-musl'
run: cargo build --release --target ${{ matrix.target }}
- name: Build | Build (musl)
if: matrix.target == 'x86_64-unknown-linux-musl'
run: cargo build --release --target ${{ matrix.target }}
- name: Post Setup | Extract tag name
shell: bash
run: echo "##[set-output name=tag;]$(echo ${GITHUB_REF#refs/tags/})"
id: extract_tag
- name: Post Setup | Prepare artifacts [Windows]
if: matrix.os == 'windows-latest'
run: |
mkdir target/stage
cd target/${{ matrix.target }}/release
strip ${{ env.CRATE_NAME }}.exe
7z a ../../stage/${{ env.CRATE_NAME }}-${{ steps.extract_tag.outputs.tag }}-${{ matrix.target }} ${{ env.CRATE_NAME }}.exe
cd -
- name: Post Setup | Prepare artifacts [-nix]
if: matrix.os != 'windows-latest'
run: |
mkdir target/stage
cd target/${{ matrix.target }}/release
strip ${{ env.CRATE_NAME }}
tar czvf ../../stage/${{ env.CRATE_NAME }}-${{ steps.extract_tag.outputs.tag }}-${{ matrix.name }} ${{ env.CRATE_NAME }}
cd -
- name: Post Setup | Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ env.CRATE_NAME }}-${{ steps.extract_tag.outputs.tag }}-${{ matrix.name }}
path: target/stage/*
# Create GitHub release with Rust build targets and release notes
github_release:
name: Create GitHub Release
needs: github_build
runs-on: ubuntu-latest
steps:
- name: Setup | Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup | Artifacts
uses: actions/download-artifact@v2
- name: Setup | Release notes
run: |
git log -1 --pretty='%s' > RELEASE.md
- name: Build | Publish
uses: softprops/action-gh-release@v1
with:
files: ${{ env.CRATE_NAME }}-*/${{ env.CRATE_NAME }}-*
body_path: RELEASE.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

53
.github/workflows/tests.yml vendored Normal file
View file

@ -0,0 +1,53 @@
name: Tests
on: [push, pull_request]
env:
RUSTFLAGS: -Dwarnings
jobs:
build_and_test:
name: Build and test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
rust: [stable]
steps:
- uses: actions/checkout@master
- name: Install ${{ matrix.rust }}
uses: actions-rs/toolchain@v1
with:
toolchain: ${{ matrix.rust }}
override: true
- name: check
uses: actions-rs/cargo@v1
with:
command: check
args: --all
- name: tests
uses: actions-rs/cargo@v1
with:
command: test
args: --all
check_fmt_and_docs:
name: Checking fmt and docs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions-rs/toolchain@v1
with:
toolchain: stable
components: rustfmt, clippy
override: true
- name: fmt
run: cargo fmt --all -- --check
- name: Docs
run: cargo doc

View file

@ -1,62 +0,0 @@
# Based on the "trust" template v0.1.2
# https://github.com/japaric/trust/tree/v0.1.2
dist: trusty
language: rust
services: docker
sudo: required
env:
global:
- CRATE_NAME=mdbook-toc
matrix:
include:
# Linux
- env: TARGET=i686-unknown-linux-gnu
- env: TARGET=x86_64-unknown-linux-gnu
# OSX
- env: TARGET=x86_64-apple-darwin
os: osx
before_install:
- set -e
- rustup self update
install:
- sh ci/install.sh
- source ~/.cargo/env || true
script:
- bash ci/script.sh
after_script: set +e
before_deploy:
- sh ci/before_deploy.sh
deploy:
api_key:
secure: "VE2CE39FAa8lSNZ4XhjN8DNMpylVmr/6PC8JvHjjhrKUfCWS6LrvYh3iSKX6bg8JHeFZWaldHK1YyVA9gJYzBjKpadKj1Ga0Hu2lFjYzFV8BBgBp2/cf63ERDbPbwbl/2OZoyEC6JrohbDHRJ34BP3jvwa80t3cc4JsiKYN6cJMVU9zsYZYuIn7uiDRJnAaxkOWxmKY1vfka/oS8x6qjn84NrhXexFNWVeJ/dB+S4JeCqa4OhiupHSRurxeFgcOzvQtaxZFumKWGX0uAXKeBuGK8lQDwIOh8yNAEbuLat8tW+zapy3Yjnqt4p0D6HdcSRhJEq5FyI3h1NruDScHcn2/TVm0Jiwl4xM9DhnrRCOW04KRl8a54cs95tC0TenboxNnW9E9J0MMq/zxFFbHhxHcH0Kn4DMjLNsxj13CaIsc8/tkUGJyq3+FrUOFI5UlEj15VQqhTnHG/vuuudRQuc7cnfUA7BWPZdhNcdTH50z4JsOSejHHBBABLTJqGY7Ra5iCTrCfE1yYbziR8QaPfwB3HNnN8JyKZchWbXO0Bv4Db0yEbKzoq7wlYJD2jp4L+UvFox0yZ0/ZZVFvOuk33ofMcXEigxt1MHrl2+0/4s//OtAn+wII7RJSit4uuzM5nn38LtMDrMGC5w+6hf2VlbUqBOjg36r7zcpx/Olpk+LM="
file_glob: true
file: $CRATE_NAME-$TRAVIS_TAG-$TARGET.*
on:
condition: $TRAVIS_RUST_VERSION = stable
tags: true
provider: releases
skip_cleanup: true
cache: cargo
before_cache:
# Travis can't cache files that are not readable by "others"
- chmod -R a+r $HOME/.cargo
branches:
only:
# release tags
- /^\d+\.\d+\.\d+.*$/
- master
notifications:
email: false

View file

@ -1,66 +0,0 @@
# Based on the "trust" template v0.1.2
# https://github.com/japaric/trust/tree/v0.1.2
environment:
global:
RUST_VERSION: stable
CRATE_NAME: mdbook-toc
matrix:
# MSVC
- TARGET: i686-pc-windows-msvc
- TARGET: x86_64-pc-windows-msvc
install:
- ps: >-
If ($Env:TARGET -eq 'x86_64-pc-windows-gnu') {
$Env:PATH += ';C:\msys64\mingw64\bin'
} ElseIf ($Env:TARGET -eq 'i686-pc-windows-gnu') {
$Env:PATH += ';C:\msys64\mingw32\bin'
}
- curl -sSf -o rustup-init.exe https://win.rustup.rs/
- rustup-init.exe -y --default-host %TARGET% --default-toolchain %RUST_VERSION%
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- rustc -Vv
- cargo -V
test_script:
# we don't run the "test phase" when doing deploys
- if [%APPVEYOR_REPO_TAG%]==[false] (
cargo test --target %TARGET% &&
cargo build --target %TARGET%
)
before_deploy:
- cargo rustc --target %TARGET% --release --bin mdbook-toc
- ps: ci\before_deploy.ps1
deploy:
artifact: /.*\.zip/
auth_token:
secure: "kTwxCDJYj3QdFwxUiCEnUN8VcFAfU6KJKttab4G9LPCkpxVNexMvFTwWkp7sgamP"
description: ''
on:
RUST_VERSION: stable
appveyor_repo_tag: true
provider: GitHub
cache:
- C:\Users\appveyor\.cargo\registry
- target
branches:
only:
# Release tags
- /^\d+\.\d+\.\d+.*$/
- master
notifications:
- provider: Email
on_build_success: false
on_build_failure: false
on_build_status_changed: false
# Building is done in the test phase, so we disable Appveyor's build phase.
build: false

View file

@ -1,22 +0,0 @@
# This script takes care of packaging the build artifacts that will go in the
# release zipfile
$SRC_DIR = $PWD.Path
$STAGE = [System.Guid]::NewGuid().ToString()
Set-Location $ENV:Temp
New-Item -Type Directory -Name $STAGE
Set-Location $STAGE
$ZIP = "$SRC_DIR\$($Env:CRATE_NAME)-$($Env:APPVEYOR_REPO_TAG_NAME)-$($Env:TARGET).zip"
Copy-Item "$SRC_DIR\target\$($Env:TARGET)\release\mdbook-toc.exe" '.\'
7z a "$ZIP" *
Push-AppveyorArtifact "$ZIP"
Remove-Item *.* -Force
Set-Location ..
Remove-Item $STAGE
Set-Location $SRC_DIR

View file

@ -1,31 +0,0 @@
# This script takes care of building your crate and packaging it for release
set -ex
main() {
local src=$(pwd) \
stage=
case $TRAVIS_OS_NAME in
linux)
stage=$(mktemp -d)
;;
osx)
stage=$(mktemp -d -t tmp)
;;
esac
test -f Cargo.lock || cargo generate-lockfile
cross rustc --bin mdbook-toc --target $TARGET --release
cp target/$TARGET/release/mdbook-toc $stage/
cd $stage
tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz *
cd $src
rm -rf $stage
}
main

View file

@ -1,47 +0,0 @@
set -ex
main() {
local target=
if [ $TRAVIS_OS_NAME = linux ]; then
target=x86_64-unknown-linux-musl
sort=sort
else
target=x86_64-apple-darwin
sort=gsort # for `sort --sort-version`, from brew's coreutils.
fi
# Builds for iOS are done on OSX, but require the specific target to be
# installed.
case $TARGET in
aarch64-apple-ios)
rustup target install aarch64-apple-ios
;;
armv7-apple-ios)
rustup target install armv7-apple-ios
;;
armv7s-apple-ios)
rustup target install armv7s-apple-ios
;;
i386-apple-ios)
rustup target install i386-apple-ios
;;
x86_64-apple-ios)
rustup target install x86_64-apple-ios
;;
esac
# This fetches latest stable release
local tag=$(git ls-remote --tags --refs --exit-code https://github.com/japaric/cross \
| cut -d/ -f3 \
| grep -E '^v[0.1.0-9.]+$' \
| $sort --version-sort \
| tail -n1)
curl -LSfs https://japaric.github.io/trust/install.sh | \
sh -s -- \
--force \
--git japaric/cross \
--tag $tag \
--target $target
}
main

View file

@ -1,18 +0,0 @@
# This script takes care of testing your crate
set -ex
main() {
cross build --target $TARGET
if [ ! -z $DISABLE_TESTS ]; then
return
fi
cross test --target $TARGET
}
# we don't run the "test phase" when doing deploys
if [ -z $TRAVIS_TAG ]; then
main
fi