Skip to content

Commit

Permalink
Improve release workflow for blazecli
Browse files Browse the repository at this point in the history
Improve the release workflow for blazecli by also creating a tag and
release for the published version.

Signed-off-by: Daniel Müller <[email protected]>
  • Loading branch information
d-e-s-o authored and danielocfb committed Dec 19, 2023
1 parent facacf9 commit 04bc85c
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 3 deletions.
40 changes: 39 additions & 1 deletion .github/workflows/publish-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,53 @@ on:
workflow_dispatch:

jobs:
version:
name: Retrieve version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- id: version
shell: bash
run: |
cd cli
cargo generate-lockfile
version="$(cargo pkgid | cut -d '#' -f2 | cut -d '@' -f2 | grep -o '[^:]*$')"
if [ -z "${version}" ]; then
echo "Invalid version number"
exit 1
fi
echo "version=${version}" >> $GITHUB_OUTPUT
test:
uses: ./.github/workflows/test.yml
secrets: inherit
publish:
needs: [test]
needs: [test, version]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
- name: Create git tag
env:
version: ${{ needs.version.outputs.version }}
run: |
curl --location \
--request POST \
--url https://api.github.com/repos/${{ github.repository }}/releases \
--header "Accept: application/vnd.github+json" \
--header "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}"\
--header "X-GitHub-Api-Version: 2022-11-28" \
--data "{
\"tag_name\":\"cli-v${version}\",
\"target_commitish\":\"${{ github.ref }}\",
\"name\":\"cli-v${version}\",
\"draft\":false,
\"prerelease\":false,
\"generate_release_notes\":false,
\"make_latest\":\"false\"
}"
- name: Publish
run: cargo publish --package blazecli --token "${CARGO_REGISTRY_TOKEN}"
env:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
shell: bash
run: |
cargo generate-lockfile
version="$(cargo pkgid | cut -d '#' -f2 | grep -o '[^:]*$')"
version="$(cargo pkgid | cut -d '#' -f2 | cut -d '@' -f2 | grep -o '[^:]*$')"
if [ -z "${version}" ]; then
echo "Invalid version number"
exit 1
Expand Down Expand Up @@ -48,7 +48,8 @@ jobs:
\"name\":\"v${version}\",
\"draft\":false,
\"prerelease\":false,
\"generate_release_notes\":false
\"generate_release_notes\":false,
\"make_latest\":\"true\"
}"
- name: Publish
run: cargo publish --no-verify --token "${CARGO_REGISTRY_TOKEN}"
Expand Down

0 comments on commit 04bc85c

Please sign in to comment.