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