-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (113 loc) · 4.4 KB
/
Copy pathrelease.yml
File metadata and controls
127 lines (113 loc) · 4.4 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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
name: Release
on:
push:
tags:
- 'v[0-9]*'
- '!v[0-9]*-rc*'
workflow_dispatch:
permissions:
contents: write
packages: write
jobs:
state:
name: Resolve release target
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.state.outputs.tag_name }}
head_sha: ${{ steps.state.outputs.head_sha }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
ref: main
# Stable releases come from a pushed tag. Release candidates are
# dispatched manually and numbered automatically (rc1, rc2, ...),
# tagging current main, exactly like the nightly flow does.
- name: Resolve release target
id: state
run: |
set -euo pipefail
event_name="${{ github.event_name }}"
if [[ "$event_name" == "push" ]]; then
echo "tag_name=${{ github.ref_name }}" >> "$GITHUB_OUTPUT"
echo "head_sha=${{ github.sha }}" >> "$GITHUB_OUTPUT"
exit 0
fi
VERSION_NAME="$(node -e 'const fs = require("fs"); const metadata = JSON.parse(fs.readFileSync("metadata.json", "utf8")); process.stdout.write(metadata["version-name"]);')"
TAG_PREFIX="v${VERSION_NAME}-rc"
LAST_RC="$(
git tag --list "${TAG_PREFIX}*" |
awk -v prefix="$TAG_PREFIX" '
index($0, prefix) == 1 {
number = substr($0, length(prefix) + 1)
if (number ~ /^[0-9]+$/) print number
}
' |
sort -n |
tail -n 1
)"
NEXT_RC=$(( ${LAST_RC:-0} + 1 ))
TAG_NAME="${TAG_PREFIX}${NEXT_RC}"
HEAD_SHA="$(git rev-parse HEAD)"
echo "tag_name=${TAG_NAME}" >> "$GITHUB_OUTPUT"
echo "head_sha=${HEAD_SHA}" >> "$GITHUB_OUTPUT"
echo "Release candidate ${TAG_NAME} will be built from ${HEAD_SHA}." >> "$GITHUB_STEP_SUMMARY"
ci:
if: ${{ github.event_name == 'workflow_dispatch' || !contains(github.ref_name, '-') }}
needs: [state]
uses: ./.github/workflows/ci.yml
with:
checkout_ref: ${{ needs.state.outputs.head_sha }}
release:
name: Create GitHub Release
if: ${{ github.event_name == 'workflow_dispatch' || !contains(github.ref_name, '-') }}
runs-on: ubuntu-latest
needs: [state, ci]
steps:
- uses: actions/checkout@v7
with:
ref: ${{ needs.state.outputs.head_sha }}
- name: Download extension zip
uses: actions/download-artifact@v8
with:
name: extension-zip
path: dist/target/
- name: Create GitHub Release
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ needs.state.outputs.tag_name }}
target_commitish: ${{ needs.state.outputs.head_sha }}
name: ${{ needs.state.outputs.tag_name }}
files: |
dist/target/aurora-shell@luminusos.github.io.shell-extension.zip
dist/target/aurora-shell@luminusos.github.io.development.shell-extension.zip
generate_release_notes: true
prerelease: ${{ github.event_name == 'workflow_dispatch' }}
# An RC supersedes the nightly line: once a release candidate is out,
# the nightly pre-releases are removed like superseded nightlies are.
- name: Delete superseded nightly pre-releases
if: ${{ github.event_name == 'workflow_dispatch' }}
env:
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
gh release list \
--limit 1000 \
--json tagName,isPrerelease \
--jq '.[] | select(.isPrerelease and (.tagName | test("-nightly[0-9]+$"))) | .tagName' |
while IFS= read -r nightly_tag; do
gh release delete "$nightly_tag" --cleanup-tag --yes
echo "Deleted superseded nightly ${nightly_tag}." >> "$GITHUB_STEP_SUMMARY"
done
- name: Create maintenance branch
if: ${{ github.event_name == 'push' }}
run: |
MAJOR=$(echo "${{ needs.state.outputs.tag_name }}" | sed 's/^v//' | grep -oP '^\d+')
BRANCH="release/v${MAJOR}.x"
if git ls-remote --exit-code --heads origin "$BRANCH" > /dev/null 2>&1; then
echo "Branch $BRANCH already exists, skipping."
else
echo "Creating branch $BRANCH"
git checkout -b "$BRANCH"
git push origin "$BRANCH"
fi