-
Notifications
You must be signed in to change notification settings - Fork 0
156 lines (156 loc) · 6.51 KB
/
Copy pathci.yml
File metadata and controls
156 lines (156 loc) · 6.51 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
name: Quality
on:
push:
branches: [main]
pull_request:
permissions:
actions: write
contents: write
pages: write
id-token: write
concurrency:
group: pages-${{ github.ref }}
cancel-in-progress: true
jobs:
test:
if: github.actor != 'github-actions[bot]'
runs-on: ubuntu-latest
outputs:
release_version: ${{ steps.persist_release.outputs.version }}
release_sha: ${{ steps.persist_release.outputs.release_sha }}
source_sha: ${{ steps.persist_release.outputs.source_sha }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-node@v7
with:
node-version: 22
cache: npm
- run: npm ci
- name: Record production version and DevLog entry
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: npm run release:auto
env:
DEVLOG_PRODUCTION: 'true'
DEVLOG_BRANCH: ${{ github.ref_name }}
DEVLOG_COMMIT_SHA: ${{ github.sha }}
DEVLOG_COMMIT_SUBJECT: ${{ github.event.head_commit.message }}
DEVLOG_AUTHOR_NAME: ${{ github.event.head_commit.author.name }}
DEVLOG_AUTHOR_LOGIN: ${{ github.actor }}
- name: Enforce production release alignment
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
run: npm run release:auto:check
env:
DEVLOG_PRODUCTION: 'true'
DEVLOG_BRANCH: ${{ github.ref_name }}
DEVLOG_COMMIT_SHA: ${{ github.sha }}
DEVLOG_COMMIT_SUBJECT: ${{ github.event.head_commit.message }}
- run: npm run check
- run: npm test
- run: npm run build
- name: Install browser used by runnable example checks
run: npx playwright install --with-deps chromium
- name: Verify runnable Howler and WaveSurfer examples
run: npm run test:browser
- run: npm run pack:check
- name: Persist generated release metadata
id: persist_release
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
shell: bash
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add package.json package-lock.json config/devlog-releases.json packages/api/package.json packages/browser/package.json packages/cli/package.json packages/cli/src/library.ts packages/core/package.json packages/howler/package.json packages/mcp/package.json packages/mcp/src/index.ts packages/wavesurfer/package.json
if git diff --cached --quiet; then
echo "Release metadata already exists for this production commit."
else
VERSION="$(node -p 'require("./package.json").version')"
git commit -m "chore(release): Audio Browser Lab v${VERSION}"
git push origin "HEAD:${{ github.ref_name }}"
fi
echo "version=$(node -p 'require("./package.json").version')" >> "$GITHUB_OUTPUT"
echo "release_sha=$(git rev-parse HEAD)" >> "$GITHUB_OUTPUT"
echo "source_sha=${{ github.sha }}" >> "$GITHUB_OUTPUT"
- name: Upload Pages artifact
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: actions/upload-pages-artifact@v5
with:
path: dist
deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: test
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v5
publish-release:
if: github.event_name == 'push' && github.ref == 'refs/heads/main' && github.actor != 'github-actions[bot]'
needs: [test, deploy]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ needs.test.outputs.release_sha }}
- name: Verify or create the release tag
shell: bash
env:
RELEASE_VERSION: ${{ needs.test.outputs.release_version }}
RELEASE_SHA: ${{ needs.test.outputs.release_sha }}
run: |
set -euo pipefail
TAG="v${RELEASE_VERSION}"
git fetch origin --force --tags
if git rev-parse --verify --quiet "refs/tags/${TAG}" >/dev/null; then
EXISTING_SHA="$(git rev-list -n 1 "${TAG}")"
if [ "${EXISTING_SHA}" != "${RELEASE_SHA}" ]; then
echo "${TAG} points to ${EXISTING_SHA}, expected ${RELEASE_SHA}." >&2
exit 1
fi
echo "${TAG} already points to the generated release commit."
else
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git tag -a "${TAG}" "${RELEASE_SHA}" -m "Audio Browser Lab ${TAG}"
git push origin "refs/tags/${TAG}"
fi
- name: Publish the GitHub Release
shell: bash
env:
GH_TOKEN: ${{ github.token }}
RELEASE_VERSION: ${{ needs.test.outputs.release_version }}
RELEASE_SHA: ${{ needs.test.outputs.release_sha }}
SOURCE_SHA: ${{ needs.test.outputs.source_sha }}
run: |
set -euo pipefail
TAG="v${RELEASE_VERSION}"
if gh release view "${TAG}" --repo "${GITHUB_REPOSITORY}" >/dev/null 2>&1; then
echo "GitHub Release ${TAG} already exists."
exit 0
fi
SHORT_SOURCE="${SOURCE_SHA:0:7}"
NOTES_FILE="$(mktemp)"
trap 'rm -f "${NOTES_FILE}"' EXIT
{
echo "Production release ${TAG}."
echo
echo "- Source commit: [${SHORT_SOURCE}](https://github.com/${GITHUB_REPOSITORY}/commit/${SOURCE_SHA})"
echo "- Release commit: [${RELEASE_SHA:0:7}](https://github.com/${GITHUB_REPOSITORY}/commit/${RELEASE_SHA})"
echo "- [Public DevLog](https://aribradshaw.github.io/audio-browser-lab/devlog/)"
} > "${NOTES_FILE}"
gh release create "${TAG}" \
--repo "${GITHUB_REPOSITORY}" \
--verify-tag \
--title "Audio Browser Lab ${TAG}" \
--notes-file "${NOTES_FILE}"
- name: Dispatch npm package publication
shell: bash
env:
GH_TOKEN: ${{ github.token }}
RELEASE_VERSION: ${{ needs.test.outputs.release_version }}
run: gh workflow run publish.yml --repo "${GITHUB_REPOSITORY}" --ref main -f "release_tag=v${RELEASE_VERSION}"