Skip to content

Commit 5b35fef

Browse files
committed
Update release workflow descriptions and improve tag handling logic
1 parent 97bf377 commit 5b35fef

2 files changed

Lines changed: 11 additions & 7 deletions

File tree

.github/workflows/release.yml

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ on:
1111
workflow_dispatch:
1212
inputs:
1313
tag:
14-
description: 'Existing git tag to release, for example v1.6.12'
14+
description: 'Release tag to publish, for example v1.6.12'
1515
required: true
1616
type: string
1717

@@ -38,7 +38,11 @@ jobs:
3838
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
3939
RELEASE_TAG='${{ github.event.inputs.tag }}'
4040
git fetch --force --tags origin
41-
git checkout "$RELEASE_TAG"
41+
42+
if git rev-parse "refs/tags/$RELEASE_TAG" >/dev/null 2>&1; then
43+
git checkout "$RELEASE_TAG"
44+
fi
45+
4246
VERSION="$(ruby -e 'require "./lib/cloudstack-cli/version"; print CloudstackCli::VERSION')"
4347
elif [ "$GITHUB_REF_TYPE" = "tag" ]; then
4448
RELEASE_TAG="$GITHUB_REF_NAME"
@@ -68,15 +72,15 @@ jobs:
6872
exit 1
6973
fi
7074
71-
- name: Create release tag from main
72-
if: github.ref_type == 'branch'
75+
- name: Create release tag from branch
76+
if: github.ref_type == 'branch' || github.event_name == 'workflow_dispatch'
7377
run: |
7478
RELEASE_TAG='${{ steps.release.outputs.release_tag }}'
7579
7680
git fetch --force --tags origin
7781
78-
if git rev-parse "$RELEASE_TAG" >/dev/null 2>&1; then
79-
TAG_SHA="$(git rev-list -n 1 "$RELEASE_TAG")"
82+
if git rev-parse "refs/tags/$RELEASE_TAG" >/dev/null 2>&1; then
83+
TAG_SHA="$(git rev-list -n 1 "refs/tags/$RELEASE_TAG")"
8084
8185
if [ "$TAG_SHA" != "$GITHUB_SHA" ]; then
8286
echo "Tag $RELEASE_TAG already exists on $TAG_SHA, expected $GITHUB_SHA."

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ The `Update bundle` workflow runs monthly and can also be started manually from
207207

208208
### Releases
209209

210-
The `Release gem` workflow publishes to RubyGems when a tag like `v1.6.12` is pushed. It also runs when `lib/cloudstack-cli/version.rb` changes on `main`, creates the matching tag automatically, and publishes that version. You can still trigger it manually for an existing tag from the Actions tab.
210+
The `Release gem` workflow publishes to RubyGems when a tag like `v1.6.12` is pushed. It also runs when `lib/cloudstack-cli/version.rb` changes on `main`, creates the matching tag automatically, and publishes that version. You can also trigger it manually from the Actions tab with a release tag like `v1.6.12`; if the tag does not exist yet, the workflow creates it from the selected branch before publishing.
211211

212212
Add the `RUBYGEMS_API_KEY` repository secret before using the release workflow.
213213

0 commit comments

Comments
 (0)