-
Notifications
You must be signed in to change notification settings - Fork 0
78 lines (66 loc) · 2.17 KB
/
Copy pathsnapshot.yml
File metadata and controls
78 lines (66 loc) · 2.17 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
name: Snapshot
on:
workflow_run:
workflows:
- CI
types:
- completed
permissions:
actions: read
contents: write
concurrency:
group: snapshot
cancel-in-progress: true
jobs:
publish:
name: Publish snapshot
if: >-
github.event.workflow_run.conclusion == 'success' &&
github.event.workflow_run.event == 'push' &&
github.event.workflow_run.head_branch == 'trunk'
runs-on: ubuntu-latest
steps:
- name: Checkout tested commit
uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_sha }}
fetch-depth: 0
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: out/release
run-id: ${{ github.event.workflow_run.id }}
github-token: ${{ github.token }}
- name: Publish snapshot prerelease
env:
GH_TOKEN: ${{ github.token }}
SNAPSHOT_SHA: ${{ github.event.workflow_run.head_sha }}
SNAPSHOT_RUN_URL: ${{ github.event.workflow_run.html_url }}
run: |
set -euo pipefail
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -f snapshot "$SNAPSHOT_SHA"
git push --force origin refs/tags/snapshot
cat > release-notes.md <<EOF
Snapshot build for \`$SNAPSHOT_SHA\`.
CI run: $SNAPSHOT_RUN_URL
EOF
if gh release view snapshot >/dev/null 2>&1; then
gh release edit snapshot \
--title snapshot \
--notes-file release-notes.md \
--prerelease \
--latest=false
else
gh release create snapshot \
--title snapshot \
--notes-file release-notes.md \
--prerelease \
--latest=false \
--target "$SNAPSHOT_SHA"
fi
gh release view snapshot --json assets --jq '.assets[].name' |
xargs -r -n 1 gh release delete-asset snapshot -y
gh release upload snapshot out/release/* --clobber