Skip to content

Commit a128add

Browse files
authored
ci: fix release workflow tag publishing (#7863)
1 parent f18fdff commit a128add

2 files changed

Lines changed: 41 additions & 13 deletions

File tree

‎.github/workflows/release_dotnet.yml‎

Lines changed: 38 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
name: Release Dotnet Binding
1919

2020
on:
21+
push:
22+
tags:
23+
- "v[0-9]+.[0-9]+.[0-9]+"
24+
- "v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+"
2125
pull_request:
2226
branches:
2327
- main
@@ -126,18 +130,41 @@ jobs:
126130
id: version
127131
shell: bash
128132
run: |
129-
case "${{ inputs.release_type }}" in
130-
rc)
131-
SUFFIX="rc"
132-
;;
133-
*)
134-
SUFFIX="preview.${GITHUB_RUN_NUMBER}"
135-
;;
136-
esac
137-
echo "VERSION_SUFFIX=${SUFFIX}" >> "$GITHUB_OUTPUT"
133+
set -euo pipefail
134+
135+
suffix=""
136+
if [[ "${GITHUB_EVENT_NAME}" == "push" && "${GITHUB_REF_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+-rc\.([0-9]+)$ ]]; then
137+
suffix="rc.${BASH_REMATCH[1]}"
138+
elif [[ "${GITHUB_EVENT_NAME}" == "push" && "${GITHUB_REF_NAME}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
139+
suffix=""
140+
else
141+
case "${{ inputs.release_type }}" in
142+
rc)
143+
suffix="rc"
144+
;;
145+
*)
146+
suffix="preview.${GITHUB_RUN_NUMBER}"
147+
;;
148+
esac
149+
fi
150+
151+
echo "version_suffix=${suffix}" >> "$GITHUB_OUTPUT"
138152
139153
- name: Pack OpenDAL
140-
run: dotnet pack OpenDAL/OpenDAL.csproj -c Release -o artifacts/package --version-suffix "${{ steps.version.outputs.VERSION_SUFFIX }}"
154+
shell: bash
155+
run: |
156+
set -euo pipefail
157+
158+
pack_args=(
159+
OpenDAL/OpenDAL.csproj
160+
-c Release
161+
-o artifacts/package
162+
)
163+
if [[ -n "${{ steps.version.outputs.version_suffix }}" ]]; then
164+
pack_args+=(--version-suffix "${{ steps.version.outputs.version_suffix }}")
165+
fi
166+
167+
dotnet pack "${pack_args[@]}"
141168
142169
- name: Upload NuGet package
143170
uses: actions/upload-artifact@v7
@@ -148,7 +175,7 @@ jobs:
148175

149176
publish:
150177
name: Publish
151-
if: ${{ github.event_name == 'workflow_dispatch' && inputs.release_type != 'none' }}
178+
if: ${{ (github.event_name == 'workflow_dispatch' && inputs.release_type != 'none') || (startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-')) }}
152179
runs-on: ubuntu-latest
153180
needs:
154181
- package

‎.github/workflows/release_ruby.yml‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,9 @@ jobs:
162162
retention-days: 30
163163

164164
publish:
165-
# allow tag releases
166-
if: startsWith(github.ref, 'refs/tags/v')
165+
# RC tags only build artifacts for release verification. RubyGems does not
166+
# provide a staging registry, so publish only from the final release tag.
167+
if: startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-')
167168

168169
needs: [build, build-native]
169170
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)