Repository navigation
163 lines (139 loc) · 5.91 KB
/
Copy pathrelease.yml
File metadata and controls
163 lines (139 loc) · 5.91 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# Copyright 2026 allurx
# SPDX-License-Identifier: Apache-2.0
name: Release
run-name: Release ${{ github.ref_name }}
on:
push:
tags:
- "v*.*.*"
permissions:
contents: read
concurrency:
group: aura-release
queue: max
jobs:
build:
name: Build release assets
runs-on: ubuntu-24.04
timeout-minutes: 20
permissions:
actions: read
contents: read
outputs:
tag_object: ${{ steps.release_tag.outputs.tag_object }}
steps:
- name: Check out repository
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- name: Validate release tag
id: release_tag
shell: bash
env:
TAG_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
if [[ ! "$TAG_NAME" =~ ^v(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$ ]]; then
echo "::error::Release tag must use the stable SemVer form vMAJOR.MINOR.PATCH"
exit 1
fi
tag_ref="refs/tags/$TAG_NAME"
if [[ "$(git cat-file -t "$tag_ref")" != "tag" ]]; then
echo "::error::Release tag must be annotated"
exit 1
fi
tag_commit="$(git rev-parse "$tag_ref^{commit}")"
if [[ "$(git rev-parse HEAD)" != "$tag_commit" ]]; then
echo "::error::The checked-out commit does not match the release tag"
exit 1
fi
if ! git merge-base --is-ancestor "$tag_commit" refs/remotes/origin/main; then
echo "::error::Release tag commit must be contained in main"
exit 1
fi
if [[ "v$(jq -er '.version' package.json)" != "$TAG_NAME" ]]; then
echo "::error::Release tag must match package.json version"
exit 1
fi
echo "tag_object=$(git rev-parse "$tag_ref")" >> "$GITHUB_OUTPUT"
echo "commit=$tag_commit" >> "$GITHUB_OUTPUT"
- name: Download verified site assets
uses: allurx/allurx-build/actions/download-verified-site-assets@e8af419cc31780e403856e40f099c03207cf6af2 # workflows-v2.2.0
with:
workflow: ci.yml
commit-sha: ${{ steps.release_tag.outputs.commit }}
web-directory: dist/web
additional-directory: dist/portable
- name: Package release assets
shell: bash
env:
TAG_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
web_asset="aura-web-$TAG_NAME.zip"
portable_asset="aura-portable-$TAG_NAME.html"
checksum_asset="aura-$TAG_NAME-SHA256SUMS.txt"
for required_file in index.html LICENSE.txt THIRD-PARTY-NOTICES.txt; do
if [[ ! -s "dist/web/$required_file" ]]; then
echo "::error::Required Web build file dist/web/$required_file was not generated"
exit 1
fi
done
if [[ ! -f dist/portable/aura.html ]] || [[ "$(find dist/portable -type f | wc -l)" -ne 1 ]]; then
echo "::error::Portable build must contain only dist/portable/aura.html"
exit 1
fi
mkdir release-assets
(
cd dist/web
zip -q -r "../../release-assets/$web_asset" .
)
cp dist/portable/aura.html "release-assets/$portable_asset"
(
cd release-assets
sha256sum "$web_asset" "$portable_asset" > "$checksum_asset"
)
- name: Upload release assets
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: release-assets-${{ github.ref_name }}
path: release-assets/
if-no-files-found: error
retention-days: 1
publish:
name: Publish GitHub Release
needs: build
runs-on: ubuntu-24.04
timeout-minutes: 5
permissions:
contents: write
steps:
- name: Download release assets
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
with:
name: release-assets-${{ github.ref_name }}
path: release-assets
- name: Publish GitHub Release
shell: bash
env:
EXPECTED_TAG_OBJECT: ${{ needs.build.outputs.tag_object }}
GH_TOKEN: ${{ github.token }}
TAG_NAME: ${{ github.ref_name }}
run: |
set -euo pipefail
remote_tag_object="$(
gh api "repos/$GITHUB_REPOSITORY/git/ref/tags/$TAG_NAME" --jq ".object.sha"
)"
if [[ "$remote_tag_object" != "$EXPECTED_TAG_OBJECT" ]]; then
echo "::error::Release tag changed after the build started"
exit 1
fi
cd release-assets
sha256sum --check aura-*-SHA256SUMS.txt
gh release create "$TAG_NAME" ./* \
--repo "$GITHUB_REPOSITORY" \
--verify-tag \
--fail-on-no-commits \
--generate-notes \
--title "$TAG_NAME"