Skip to content

Commit 88e7d1d

Browse files
committed
ci: add Release and Promote workflows
Automate the library release flow, adapting the pattern from scality/nodeip-discovery#2 for a pure Go library (no container/binary artifact): - release.yaml: manual dispatch to compute the next semver (alpha/beta/GA x patch/minor/major) and push an annotated v* tag. - promote.yaml: on a v* tag push, create a GitHub Release with generated notes, marking prereleases when the tag has a hyphen. The reference build.yaml/post-merge.yaml and the promote build job are omitted since a library ships as a git tag consumed via `go get`, not a Docker image. Issue: ARTESCA-17773
1 parent 9abc648 commit 88e7d1d

2 files changed

Lines changed: 114 additions & 0 deletions

File tree

.github/workflows/promote.yaml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Promote
2+
run-name: "Promote ${{ github.ref_name }}"
3+
4+
on:
5+
push:
6+
tags:
7+
- "v*"
8+
9+
jobs:
10+
create-release:
11+
runs-on: ubuntu-24.04
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
15+
with:
16+
# NOTE: We explicitly set the refs otherwise the tag
17+
# annotations content is not fetched
18+
# See: https://github.com/actions/checkout/issues/882
19+
ref: ${{ github.ref }}
20+
21+
- uses: softprops/action-gh-release@718ea10b132b3b2eba29c1007bb80653f286566b # v3.0.1
22+
with:
23+
name: raidmgmt ${{ github.ref_name }}
24+
tag_name: ${{ github.ref_name }}
25+
generate_release_notes: true
26+
# We consider pre-releases if the tag contains a hyphen
27+
# e.g. v1.2.3-alpha.0
28+
prerelease: ${{ contains(github.ref_name, '-') }}
29+
draft: false
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.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@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
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@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
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 "raidmgmt ${{ env.RELEASE_TAG }}"
83+
git push origin "${{ env.RELEASE_TAG }}"

0 commit comments

Comments
 (0)