@@ -0,0 +1,63 @@
1+name: Release
2+
3+# Every push to master builds the extension and publishes it as a GitHub release.
4+# The version is the commit's timestamp in UTC, YYYY.MM.DD.HHMM, used as the tag and release name.
5+on:
6+ push:
7+ branches: [master]
8+
9+permissions:
10+ contents: write
11+
12+concurrency:
13+ group: release-${{ github.sha }}
14+
15+jobs:
16+ release:
17+ runs-on: ubuntu-latest
18+ steps:
19+ - uses: actions/checkout@v4
20+
21+ - uses: actions/setup-node@v4
22+ with:
23+ node-version: 22
24+ cache: npm
25+
26+ - uses: actions/setup-python@v5
27+ with:
28+ python-version: "3.12"
29+
30+ - name: Install dependencies
31+ run: npm ci
32+
33+ - name: Version from commit time
34+ id: version
35+ run: |
36+ version=$(TZ=UTC git log -1 --format=%cd --date=format-local:%Y.%m.%d.%H%M "$GITHUB_SHA")
37+ echo "version=$version" >> "$GITHUB_OUTPUT"
38+ echo "Version $version"
39+
40+ - name: Typecheck and test
41+ run: npm run check
42+
43+ - name: Build
44+ env:
45+ DIAGONAL_VERSION: ${{ steps.version.outputs.version }}
46+ run: |
47+ npm run build
48+ (cd dist && zip -qr "../diagonal-extension-${DIAGONAL_VERSION}.zip" .)
49+ cat dist/manifest.json | head -5
50+
51+ - name: Publish release
52+ env:
53+ GH_TOKEN: ${{ github.token }}
54+ VERSION: ${{ steps.version.outputs.version }}
55+ run: |
56+ asset="diagonal-extension-${VERSION}.zip"
57+ notes="Built from ${GITHUB_SHA::7}. Unzip and load the folder at brave://extensions (Developer mode → Load unpacked)."
58+ if gh release view "$VERSION" >/dev/null 2>&1; then
59+ # Two commits in the same minute share a version: refresh the asset on the existing release.
60+ gh release upload "$VERSION" "$asset" --clobber
61+ else
62+ gh release create "$VERSION" "$asset" --target "$GITHUB_SHA" --title "Diagonal $VERSION" --notes "$notes"
63+ fi