-
Notifications
You must be signed in to change notification settings - Fork 0
175 lines (152 loc) · 6.56 KB
/
prerelease.yml
File metadata and controls
175 lines (152 loc) · 6.56 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
164
165
166
167
168
169
170
171
172
173
174
175
name: Publish Development Pre-release
run-name: ${{ github.actor }} triggered development pre-release from ${{ github.event.inputs.ref || github.ref_name }}
on:
workflow_dispatch:
inputs:
ref:
description: "Branch or commit to pre-release (recommended: develop)"
required: true
type: string
concurrency:
group: prerelease-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: write
jobs:
build-artifacts:
uses: ./.github/workflows/_build-platform-artifacts.yml
with:
source_ref: ${{ github.event.inputs.ref }}
artifact_name_prefix: corese-gui-prerelease
publish-prerelease:
name: Publish or update dev-prerelease
needs: build-artifacts
runs-on: ubuntu-24.04
steps:
- name: Resolve source commit
id: source-commit
uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.ref }}
fetch-depth: 1
- name: Capture source commit SHA
id: source-sha
shell: bash
run: echo "sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
- name: Move dev-prerelease tag to source commit
uses: actions/github-script@v7
env:
TARGET_SHA: ${{ steps.source-sha.outputs.sha }}
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const ref = "tags/dev-prerelease";
const sha = process.env.TARGET_SHA;
try {
await github.rest.git.getRef({ owner, repo, ref });
await github.rest.git.updateRef({
owner,
repo,
ref,
sha,
force: true
});
core.info(`Moved ${ref} to ${sha}`);
} catch (error) {
if (error.status === 404) {
await github.rest.git.createRef({
owner,
repo,
ref: `refs/${ref}`,
sha
});
core.info(`Created refs/${ref} at ${sha}`);
return;
}
throw error;
}
- name: Download all pre-release artifacts
uses: actions/download-artifact@v4
with:
pattern: corese-gui-prerelease-*
merge-multiple: true
path: build/prerelease-assets
- name: Generate build timestamp
id: timestamp
run: |
echo "timestamp=$(date -u '+%Y-%m-%d %H:%M:%S UTC')" >> "$GITHUB_OUTPUT"
- name: Extract latest changelog section for prerelease
run: |
set -euo pipefail
awk '
/^## Version / {
if (capturing) {
exit
}
capturing = 1
}
capturing { print }
' CHANGELOG.md > prerelease_changelog.raw.md
sed '/./,$!d' prerelease_changelog.raw.md | tac | sed '/./,$!d' | tac > prerelease_changelog.md
if [[ ! -s prerelease_changelog.md ]]; then
echo "No changelog section found in CHANGELOG.md" >&2
exit 1
fi
{
printf '%s\n' 'Latest unsigned multi-platform build from the selected source ref.'
printf '\n'
printf 'Last updated: %s\n' '${{ steps.timestamp.outputs.timestamp }}'
printf 'Source ref: `%s`\n' '${{ github.event.inputs.ref }}'
printf 'Commit: `%s`\n' '${{ steps.source-sha.outputs.sha }}'
printf '\n'
printf '%s\n' '## Changelog'
printf '\n'
} > prerelease_notes.md
cat prerelease_changelog.md >> prerelease_notes.md
- name: Generate checksums
run: |
cd build/prerelease-assets
find . -type f -print0 | sort -z | xargs -0 sha256sum > SHA256SUMS.txt
- name: Remove existing dev-prerelease assets
uses: actions/github-script@v7
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const tag = "dev-prerelease";
try {
const release = await github.rest.repos.getReleaseByTag({ owner, repo, tag });
const assets = release.data.assets ?? [];
if (assets.length === 0) {
core.info("No existing assets to remove.");
return;
}
core.info(`Removing ${assets.length} existing asset(s) from ${tag}.`);
for (const asset of assets) {
await github.rest.repos.deleteReleaseAsset({
owner,
repo,
asset_id: asset.id
});
core.info(`Deleted asset: ${asset.name}`);
}
} catch (error) {
if (error.status === 404) {
core.info("Release does not exist yet; nothing to clean.");
return;
}
throw error;
}
- name: Publish single rolling pre-release
uses: ncipollo/release-action@v1
with:
artifacts: "build/prerelease-assets/*"
tag: dev-prerelease
name: Development Pre-release
bodyFile: prerelease_notes.md
commit: ${{ steps.source-sha.outputs.sha }}
prerelease: true
allowUpdates: true
removeArtifacts: true
replacesArtifacts: true