Repository navigation
142 lines (120 loc) · 4.18 KB
/
Copy pathrelease.yml
File metadata and controls
142 lines (120 loc) · 4.18 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
name: Release artifacts
on:
workflow_dispatch:
inputs:
force:
description: Force a rebuild and re-upload even if the release already exists
required: false
default: false
type: boolean
push:
branches:
- main
jobs:
prepare-release:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version: ${{ steps.version.outputs.version }}
tag: ${{ steps.version.outputs.tag }}
release_exists: ${{ steps.release.outputs.exists }}
should_release: ${{ steps.decision.outputs.should_release }}
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Read manifest version
id: version
run: |
VERSION="$(node -p "require('./manifest.json').version")"
echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
echo "tag=v${VERSION}" >> "$GITHUB_OUTPUT"
- name: Check for existing GitHub release
id: release
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh release view "${{ steps.version.outputs.tag }}" --repo "${{ github.repository }}" >/dev/null 2>&1; then
echo "exists=true" >> "$GITHUB_OUTPUT"
else
echo "exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Decide whether to publish
id: decision
env:
FORCE_RELEASE: ${{ github.event_name == 'workflow_dispatch' && inputs.force || 'false' }}
RELEASE_EXISTS: ${{ steps.release.outputs.exists }}
run: |
if [ "$FORCE_RELEASE" = "true" ] || [ "$RELEASE_EXISTS" != "true" ]; then
echo "should_release=true" >> "$GITHUB_OUTPUT"
else
echo "should_release=false" >> "$GITHUB_OUTPUT"
fi
build-release-artifacts:
needs: prepare-release
if: needs.prepare-release.outputs.should_release == 'true'
runs-on: ubuntu-latest
environment: copilot
permissions:
contents: write
steps:
- name: Check out repository
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version-file: .nvmrc
cache: npm
- name: Install dependencies
run: npm ci
- name: Verify manifest-driven version sync
run: npm run version:check
- name: Clean release workspace
run: npm run release:clean
- name: Fetch Clang artifacts
run: npm run fetch-clang
- name: Run linter
run: npm run lint
- name: Build project
run: npm run build
- name: Verify release version sync
run: npm run release:check-version
- name: Run end-to-end tests
run: npm run test:e2e
- name: Package release artifacts
run: npm run package:release
- name: Publish GitHub release assets
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ needs.prepare-release.outputs.tag }}
run: |
mapfile -d '' -t RELEASE_ASSETS < <(find release -type f -print0)
if [ "${#RELEASE_ASSETS[@]}" -eq 0 ]; then
echo "::error::No release files were generated."
exit 1
fi
if gh release view "$RELEASE_TAG" --repo "${{ github.repository }}" >/dev/null 2>&1; then
gh release upload "$RELEASE_TAG" "${RELEASE_ASSETS[@]}" --clobber --repo "${{ github.repository }}"
else
gh release create "$RELEASE_TAG" "${RELEASE_ASSETS[@]}" \
--repo "${{ github.repository }}" \
--target "${{ github.sha }}" \
--title "$RELEASE_TAG" \
--generate-notes
fi
skip-existing-release:
needs: prepare-release
if: needs.prepare-release.outputs.should_release != 'true'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Skip duplicate release
run: |
echo "GitHub Release ${{ needs.prepare-release.outputs.tag }} already exists."
echo "Use workflow_dispatch with force=true to rebuild and re-upload release assets."