From fd7a92ff55e46b72b0e3c066163c3f0b849acc47 Mon Sep 17 00:00:00 2001 From: Adam Burkhalter Date: Sun, 3 Jul 2022 11:44:59 -0700 Subject: [PATCH 1/2] Add github action to auto-publish crate when cargo.toml version is bumped. #35 --- .github/workflows/ci.yaml | 53 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 486e027..d669e7f 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -98,3 +98,56 @@ jobs: - name: Test run: cd teloc_macros && cargo test + release-github: + name: Release on GitHub + needs: + - code-checks-teloc + - code-checks-macros + - test-teloc + - build-macro + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Parse release version + id: release + run: echo ::set-output name=VERSION::${GITHUB_REF#refs/tags/v} + - name: Verify release version matches `teloc_macros` Cargo manifest + run: >- + test "${{ steps.release.outputs.VERSION }}" \ + == "$(grep -m1 'version = "' teloc_macros/Cargo.toml | cut -d '"' -f2)" + - name: Verify release version matches `teloc` Cargo manifest + run: >- + test "${{ steps.release.outputs.VERSION }}" \ + == "$(grep -m1 'version = "' teloc/Cargo.toml | cut -d '"' -f2)" + - uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + name: ${{ steps.release.outputs.VERSION }} + body: | + [API docs](https://docs.rs/cucumber/${{ steps.release.outputs.VERSION }}) + prerelease: ${{ contains(steps.release.outputs.VERSION, '-') }} + + release-crate: + name: Release on crates.io + needs: ["release-github"] + if: ${{ startsWith(github.ref, 'refs/tags/v') }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + + - name: Publish `teloc_macros` crate + run: cargo publish -p teloc_macros + --token ${{ secrets.CRATESIO_TOKEN }} + + - name: Wait crates.io index is updated + run: sleep 120 + + - name: Publish `teloc` crate + run: cargo publish -p teloc + --token ${{ secrets.CRATESIO_TOKEN }} From a9ccbb6a8bc86457ffabf168414ccf8f367c5bcb Mon Sep 17 00:00:00 2001 From: Adam Burkhalter Date: Sat, 9 Jul 2022 11:01:10 -0700 Subject: [PATCH 2/2] Add minimum required github token permissions for release-github job --- .github/workflows/ci.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d669e7f..8dc04b9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -100,6 +100,9 @@ jobs: release-github: name: Release on GitHub + permissions: + contents: read + deployments: write needs: - code-checks-teloc - code-checks-macros