-
Notifications
You must be signed in to change notification settings - Fork 89
119 lines (105 loc) · 3.82 KB
/
Copy pathrelease.yml
File metadata and controls
119 lines (105 loc) · 3.82 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
name: Release
on:
workflow_run:
workflows: ["Test"]
branches:
- main
types:
- completed
permissions:
contents: write
jobs:
goreleaser:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate version tag
id: version
run: |
# Get commit count as version number
COUNT=$(git rev-list --count HEAD)
SHORT_SHA=$(git rev-parse --short=6 HEAD)
# Convert 6-char hex SHA to octal, prefixed with 9 to ensure valid semver
SHA_OCTAL=$(printf '%o' "0x${SHORT_SHA}")
VERSION="0.${COUNT}.9${SHA_OCTAL}"
TAG="v${VERSION}"
echo "version=${VERSION}" >> $GITHUB_OUTPUT
echo "tag=${TAG}" >> $GITHUB_OUTPUT
echo "sha=${SHORT_SHA}" >> $GITHUB_OUTPUT
# Create and push tag
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git tag -a "${TAG}" -m "Release ${TAG} (${SHORT_SHA})"
git push origin "${TAG}"
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
cache: true
- name: Set up pnpm
uses: pnpm/action-setup@v4
with:
version: 9
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '24'
cache: 'pnpm'
cache-dependency-path: ui/pnpm-lock.yaml
- name: Build UI
env:
# Drop JS source maps from release binaries (~6MB compressed) since
# they're only useful with devtools open. Dev builds keep them.
NO_SOURCEMAPS: '1'
run: |
cd ui
pnpm install --frozen-lockfile
pnpm run build
- name: Build templates
run: |
for dir in templates/*/; do
name=$(basename "$dir")
echo "Creating $name.tar.gz..."
tar -czf "templates/$name.tar.gz" -C "templates/$name" --exclude='.DS_Store' .
done
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
- name: Resolve headless-shell stable version
id: headless
run: |
VERSION=$(python3 scripts/extract-headless-shell.py --resolve-version)
TAG="headless-shell/v${VERSION}"
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "tag=$TAG" >> $GITHUB_OUTPUT
# Check if this version is already released
if gh release view "$TAG" >/dev/null 2>&1; then
echo "skip=true" >> $GITHUB_OUTPUT
echo "headless-shell $VERSION already released"
else
echo "skip=false" >> $GITHUB_OUTPUT
echo "headless-shell $VERSION is new, will release"
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Extract and release headless-shell
if: steps.headless.outputs.skip != 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
python3 scripts/extract-headless-shell.py dist/headless-shell
gh release create "${{ steps.headless.outputs.tag }}" \
--title "headless-shell ${{ steps.headless.outputs.version }}" \
--notes "Chromium headless-shell ${{ steps.headless.outputs.version }} extracted from chromedp/headless-shell:stable" \
dist/headless-shell/headless-shell-linux-*.tar.gz \
dist/headless-shell/headless-shell-version.txt