Skip to content

Commit

Permalink
Use output of --version in release workflow instead of manual input
Browse files Browse the repository at this point in the history
This automatically synchronizes the version of a release with the
version in Cargo.toml. In case we forget to bump the version in
Cargo.toml, the release will fail since the git tag will already exist.

CMK-18367
  • Loading branch information
jherbel committed Jul 22, 2024
1 parent 99ca351 commit 93e8520
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
---
name: "Release"
# Careful! This pushes a git tag to GitHub! The release itself is private.
on:
workflow_dispatch:
inputs:
tag:
description: >
Tag, which is set by the this GitHub workflow.
Should follow SemVer and is not allowed to exist already.
required: true
type: string
on: workflow_dispatch

jobs:
tests:
Expand All @@ -27,6 +18,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: actions-rust-lang/[email protected]
with:
target: x86_64-unknown-linux-gnu

- uses: actions/download-artifact@v4
with:
name: rcc
Expand All @@ -39,12 +34,18 @@ jobs:

- run: zip -r executables.zip artifact

- name: "Compute release tag"
id: compute-tag
run: |
version="$(cargo run --bin robotmk_scheduler -- --version | cut --delimiter " " --fields 2)"
echo "TAG=v${version}" >> "${GITHUB_OUTPUT}"
- name: "Push release tag"
# This is publicly visible and needs to be manually fixed if any
# consecutive step fails.
run: |
git tag ${{ inputs.tag }} # Fails, if tag exists.
git push origin ${{ inputs.tag }}
git tag ${{ steps.compute-tag.outputs.TAG }} # Fails, if tag exists.
git push origin ${{ steps.compute-tag.outputs.TAG }}
- uses: ncipollo/[email protected]
with:
Expand All @@ -58,4 +59,4 @@ jobs:
artifactErrorsFailBuild: true
updateOnlyUnreleased: true
makeLatest: false
tag: ${{ inputs.tag }}
tag: ${{ steps.compute-tag.outputs.TAG }}

0 comments on commit 93e8520

Please sign in to comment.