Skip to content

Commit bbd90d9

Browse files
Merge pull request #5 from scality/release-workflow
ARTESCA-16170: Add release workflow
2 parents d5a15b7 + 6114c99 commit bbd90d9

File tree

1 file changed

+83
-0
lines changed

1 file changed

+83
-0
lines changed

.github/workflows/release.yaml

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: "Release"
2+
run-name: Release new ${{ inputs.version-type }} from ${{ github.ref_name }}
3+
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
version-type:
8+
description: "Version type"
9+
required: true
10+
type: choice
11+
default: "alpha"
12+
options:
13+
- "alpha"
14+
- "beta"
15+
- "GA"
16+
version-scope:
17+
description: "Version scope"
18+
required: true
19+
type: choice
20+
default: "patch"
21+
options:
22+
- "patch"
23+
- "minor"
24+
- "major"
25+
26+
jobs:
27+
prepare-version:
28+
runs-on: ubuntu-24.04
29+
if: github.ref_name == 'main'
30+
steps:
31+
- uses: actions/create-github-app-token@v2
32+
id: app-token
33+
# NOTE: This is needed otherwise it's the same user that create the tag
34+
# than the one triggering the workflow on push tag which does not work
35+
with:
36+
app-id: ${{ vars.ACTIONS_APP_ID }}
37+
private-key: ${{ secrets.ACTIONS_APP_PRIVATE_KEY }}
38+
- name: Checkout
39+
uses: actions/checkout@v4
40+
with:
41+
fetch-depth: 0
42+
token: ${{ steps.app-token.outputs.token }}
43+
- name: Install semver tool
44+
run: |
45+
curl --fail -LO https://raw.githubusercontent.com/fsaintjacques/semver-tool/3.4.0/src/semver
46+
chmod +x ./semver
47+
- name: Compose release tag
48+
run: |
49+
last_ga_tag=$(git tag --sort=taggerdate --list "v*" | grep -v '\-' | tail -n 1)
50+
if [[ -z "$last_ga_tag" ]]; then
51+
last_ga_tag="0.0.0"
52+
fi
53+
54+
new_version=$(./semver bump ${{ inputs.version-scope }} "$last_ga_tag")
55+
56+
if [[ "${{ inputs.version-type }}" == "alpha" ]] || [[ "${{ inputs.version-type }}" == "beta" ]]; then
57+
last_pre_tag=$(git tag --sort=taggerdate --list "v$new_version-${{ inputs.version-type }}.*" | tail -n 1)
58+
if [[ -z "$last_pre_tag" ]]; then
59+
new_version=$new_version-${{ inputs.version-type }}.1
60+
else
61+
new_version=$(./semver bump prerel "$last_pre_tag")
62+
fi
63+
fi
64+
65+
if [[ "${new_version:0:1}" != "v" ]]; then
66+
new_version="v$new_version"
67+
fi
68+
69+
echo "New version: $new_version"
70+
echo "RELEASE_TAG=$new_version" >> $GITHUB_ENV
71+
- name: Validate ${{ env.RELEASE_TAG }} tag
72+
run: ./semver validate ${{ env.RELEASE_TAG }}
73+
74+
- name: Create and push `${{ env.RELEASE_TAG }}` tag
75+
run: |
76+
git fsck
77+
git gc
78+
79+
git config --global user.email ${{ github.actor }}@scality.com
80+
git config --global user.name ${{ github.actor }}
81+
82+
git tag -a "${{ env.RELEASE_TAG }}" -m "Go-errors ${{ env.RELEASE_TAG }}"
83+
git push origin "${{ env.RELEASE_TAG }}"

0 commit comments

Comments
 (0)