diff options
author | Jan-Erik Rediger <janerik@fnordig.de> | 2021-01-05 20:39:27 +0100 |
---|---|---|
committer | Jan-Erik Rediger <janerik@fnordig.de> | 2021-01-05 20:39:27 +0100 |
commit | 3580cba26d9d003a2f7648a8332c1b5da8320489 (patch) | |
tree | aaf88003c8ea98ea71929cba3c0ebbde27eb2e73 /.github | |
parent | 5a74024e5842e9b926f458250271a7b72aab4e53 (diff) |
Switch to GitHub Actions
Diffstat (limited to '.github')
-rw-r--r-- | .github/workflows/deploy.yml | 124 | ||||
-rw-r--r-- | .github/workflows/tests.yml | 53 |
2 files changed, 177 insertions, 0 deletions
diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..c5bc3aa --- /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-open-on-gh + +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 |