diff options
author | Jan-Erik Rediger <janerik@fnordig.de> | 2021-01-05 20:42:38 +0100 |
---|---|---|
committer | Jan-Erik Rediger <janerik@fnordig.de> | 2021-01-05 20:42:38 +0100 |
commit | d2799296bf23f8a99c86ed686340fa2e413e4c80 (patch) | |
tree | b2cfef1ba6cae2c1bdf55144d1ea1929bb0ced55 | |
parent | bd0d726f37c477f8c1c485ad924abe961387a407 (diff) |
Switch to GitHub Actions
-rw-r--r-- | .github/workflows/deploy.yml | 124 | ||||
-rw-r--r-- | .github/workflows/tests.yml | 53 | ||||
-rw-r--r-- | .travis.yml | 62 | ||||
-rw-r--r-- | appveyor.yml | 66 | ||||
-rw-r--r-- | ci/before_deploy.ps1 | 22 | ||||
-rw-r--r-- | ci/before_deploy.sh | 31 | ||||
-rw-r--r-- | ci/install.sh | 47 | ||||
-rw-r--r-- | ci/script.sh | 18 |
8 files changed, 177 insertions, 246 deletions
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..8441eb0 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -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-mermaid + +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 }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..d512b94 --- /dev/null +++ b/.github/workflows/tests.yml @@ -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 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4a78aa1..0000000 --- a/.travis.yml +++ /dev/null @@ -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-mermaid - -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: "Jb+Qc9XCkIg6ygOgqRN5tLGMGDmaqeUGXmAcX8CMjI3SPGkI4ewRgHdpyF/47CJ+aORU9AtpX5m73hz6hqOTcgBQoPhwAm8Rly/e14YMr7blobVvaMMV7hzaag0cApW/QyKvyJCHPxBN6Fz7y3Gje0hzdt9dEXbWdhFyHzGBpB2g42Cr7lHA/9+uqbv6tKRGJkQb7htDJypuilpLwtzFUXPjbyN0r5wteOXFdPtnM7y/bk4z/72lGhsg3ItA5nTsRJUlaHqbj2AS2sILpb+LpcMa62cfxx5cSGXqI+FEHM0HwaRzbVZyUCtKrKY2C6gpGL/ujKppv6DwhjXHOGqHNSfRtWV+ZlzJ5l+92RrZQ4Xt5P2l9splZsOp3WpRmuETFg1q+qwrY1ErEsS7XGb2/QHwqRrnvYA/gUrUM8I2lp2pSyBbUOrUkCNdG76miUafCUdAiJwUVw32JwMDPnQQI5SNX0H64VK4WOcXsOnl+mqu97bW/x4EWMxGeouLp/496q6qD1jl1B5+9srbGJOgtc4a1qlo1WXcqurJmjC2fnNRmjwOKlvd3zKGq0NmfQRRlOZxMcu5omCxapMIG5fVPKgN3bJFThqY/yHtr8bhjmSJlItCMsFwq9dAm4rM3Iz+Ux+bvHIj8WWtpRrKBc3KbuigjWmnW+/k0XhxsXX4JNQ=" - 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 diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index feef5ef..0000000 --- a/appveyor.yml +++ /dev/null @@ -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-mermaid - - 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-mermaid - - ps: ci\before_deploy.ps1 - -deploy: - artifact: /.*\.zip/ - auth_token: - secure: "YyEqam64ohhhaqHRFeV5sf5F1Pd9CYs6PS8RdR8K3Dtl35ocrBXPtl078tSDMUkz" - 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 diff --git a/ci/before_deploy.ps1 b/ci/before_deploy.ps1 deleted file mode 100644 index 6f66245..0000000 --- a/ci/before_deploy.ps1 +++ /dev/null @@ -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-mermaid.exe" '.\' - -7z a "$ZIP" * - -Push-AppveyorArtifact "$ZIP" - -Remove-Item *.* -Force -Set-Location .. -Remove-Item $STAGE -Set-Location $SRC_DIR diff --git a/ci/before_deploy.sh b/ci/before_deploy.sh deleted file mode 100644 index c843ffe..0000000 --- a/ci/before_deploy.sh +++ /dev/null @@ -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-mermaid --target $TARGET --release - - cp target/$TARGET/release/mdbook-mermaid $stage/ - - cd $stage - tar czf $src/$CRATE_NAME-$TRAVIS_TAG-$TARGET.tar.gz * - cd $src - - rm -rf $stage -} - -main diff --git a/ci/install.sh b/ci/install.sh deleted file mode 100644 index 80e18e4..0000000 --- a/ci/install.sh +++ /dev/null @@ -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 diff --git a/ci/script.sh b/ci/script.sh deleted file mode 100644 index e61e155..0000000 --- a/ci/script.sh +++ /dev/null @@ -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 |