forked from companion-inc/feynman
-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (156 loc) · 5.21 KB
/
publish.yml
File metadata and controls
163 lines (156 loc) · 5.21 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
157
158
159
160
161
162
163
name: Publish and Release
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: "true"
on:
push:
branches: [main]
workflow_dispatch:
jobs:
version-check:
runs-on: ubuntu-latest
permissions:
contents: read
outputs:
version: ${{ steps.version.outputs.version }}
should_release: ${{ steps.version.outputs.should_release }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
- id: version
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
LOCAL=$(node -p "require('./package.json').version")
echo "version=$LOCAL" >> "$GITHUB_OUTPUT"
PUBLISHED=$(npm view @companion-ai/feynman version 2>/dev/null || true)
if [ "$PUBLISHED" = "$LOCAL" ] || gh release view "v$LOCAL" >/dev/null 2>&1; then
echo "should_release=false" >> "$GITHUB_OUTPUT"
else
echo "should_release=true" >> "$GITHUB_OUTPUT"
fi
verify:
needs: version-check
if: needs.version-check.outputs.should_release == 'true'
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm test
- run: npm pack
publish-npm:
needs:
- version-check
- verify
if: needs.version-check.outputs.should_release == 'true' && needs.verify.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
registry-url: "https://registry.npmjs.org"
- run: npm ci
- run: npm publish --provenance --access public
build-native-bundles:
needs: version-check
if: needs.version-check.outputs.should_release == 'true'
strategy:
fail-fast: false
matrix:
include:
- id: linux-x64
os: ubuntu-latest
- id: darwin-x64
os: macos-15-intel
- id: darwin-arm64
os: macos-14
- id: win32-x64
os: windows-latest
runs-on: ${{ matrix.os }}
permissions:
contents: read
steps:
- uses: actions/checkout@v6
- uses: actions/setup-node@v6
with:
node-version: 24
- run: npm ci --ignore-scripts
- run: npm run build
- run: npm run build:native-bundle
- name: Smoke native bundle (Unix)
if: matrix.id != 'win32-x64'
shell: bash
run: |
VERSION=$(node -p "require('./package.json').version")
tmp=$(mktemp -d)
tar -xzf "dist/release/feynman-${VERSION}-${{ matrix.id }}.tar.gz" -C "$tmp"
"$tmp/feynman-${VERSION}-${{ matrix.id }}/feynman" --help >/tmp/feynman-help.out
head -20 /tmp/feynman-help.out
- name: Smoke native bundle (Windows)
if: matrix.id == 'win32-x64'
shell: pwsh
run: |
$version = node -p "require('./package.json').version"
$tmp = Join-Path $env:RUNNER_TEMP ("feynman-smoke-" + [guid]::NewGuid().ToString("N"))
New-Item -ItemType Directory -Path $tmp | Out-Null
Expand-Archive -LiteralPath "dist/release/feynman-$version-win32-x64.zip" -DestinationPath $tmp -Force
$bundleRoot = Join-Path $tmp "feynman-$version-win32-x64"
& (Join-Path $bundleRoot "feynman.cmd") --help | Select-Object -First 20
- uses: actions/upload-artifact@v4
with:
name: native-${{ matrix.id }}
path: dist/release/*
release-github:
needs:
- version-check
- publish-npm
- build-native-bundles
if: needs.version-check.outputs.should_release == 'true' && needs.publish-npm.result == 'success' && needs.build-native-bundles.result == 'success'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- uses: actions/download-artifact@v4
with:
path: release-assets
merge-multiple: true
- name: Build release notes
shell: bash
env:
VERSION: ${{ needs.version-check.outputs.version }}
run: |
node scripts/extract-release-notes.mjs "$VERSION" "$RUNNER_TEMP/release-notes.md"
- name: Create GitHub release
shell: bash
env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.version-check.outputs.version }}
run: |
if gh release view "v$VERSION" >/dev/null 2>&1; then
gh release upload "v$VERSION" release-assets/* --clobber
gh release edit "v$VERSION" \
--title "v$VERSION" \
--notes-file "$RUNNER_TEMP/release-notes.md" \
--draft=false \
--latest
else
gh release create "v$VERSION" release-assets/* \
--title "v$VERSION" \
--notes-file "$RUNNER_TEMP/release-notes.md" \
--target "$GITHUB_SHA"
fi