-
Notifications
You must be signed in to change notification settings - Fork 4
191 lines (160 loc) · 5.52 KB
/
release.yml
File metadata and controls
191 lines (160 loc) · 5.52 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
name: Release
on:
push:
branches:
- main
workflow_dispatch:
permissions:
contents: write
actions: write
jobs:
extract-version:
name: Extract version
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.version }}
should_release: ${{ steps.check.outputs.should_release }}
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Extract version from package.json
id: version
run: |
VERSION=$(node -p "require('./npm/package.json').version")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Extracted version: $VERSION"
- name: Check if release exists
id: check
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION="${{ steps.version.outputs.version }}"
# Check if GitHub release exists
if gh release view "v$VERSION" >/dev/null 2>&1; then
echo "Release v$VERSION already exists, skipping release"
echo "should_release=false" >> $GITHUB_OUTPUT
exit 0
fi
echo "Release v$VERSION does not exist, proceeding with release"
echo "should_release=true" >> $GITHUB_OUTPUT
ci:
name: Run CI
needs: extract-version
if: needs.extract-version.outputs.should_release == 'true'
uses: ./.github/workflows/ci.yml
build:
name: Build
needs: [extract-version, ci]
if: needs.extract-version.outputs.should_release == 'true'
uses: ./.github/workflows/build.yml
with:
version: ${{ needs.extract-version.outputs.version }}
upload-artifacts: true
retention-days: 1
release:
name: Create GitHub Release
needs: [extract-version, ci, build]
if: needs.extract-version.outputs.should_release == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Prepare release assets
run: |
mkdir -p release-assets
find artifacts -type f \( -name 'sym-darwin-*' -o -name 'sym-linux-*' -o -name 'sym-windows-*' \) -exec mv {} release-assets/ \;
# Verify binary count
BINARY_COUNT=$(ls -1 release-assets/ | wc -l)
echo "Found $BINARY_COUNT binaries"
if [ "$BINARY_COUNT" -ne 5 ]; then
echo "Error: Expected 5 binaries, found $BINARY_COUNT"
ls -lh release-assets/
exit 1
fi
echo "All 5 binaries prepared successfully"
ls -lh release-assets/
- name: Create Release
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ needs.extract-version.outputs.version }}
name: Release v${{ needs.extract-version.outputs.version }}
files: release-assets/*
generate_release_notes: true
draft: false
prerelease: false
fail_on_unmatched_files: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
npm:
name: Publish to npm
needs: [extract-version, ci, build, release]
if: needs.extract-version.outputs.should_release == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: Copy binaries to npm package
run: |
mkdir -p npm/bin
find artifacts -type f \( -name 'sym-*' ! -name '*.js' \) -exec cp {} npm/bin/ \;
# Set executable permissions for Unix binaries
chmod +x npm/bin/sym-darwin-* npm/bin/sym-linux-* 2>/dev/null || true
# Verify binary count
BINARY_COUNT=$(find npm/bin -name 'sym-*' -type f ! -name '*.js' | wc -l)
echo "Found $BINARY_COUNT binaries in npm/bin/"
if [ "$BINARY_COUNT" -ne 5 ]; then
echo "Error: Expected 5 binaries, found $BINARY_COUNT"
ls -lh npm/bin/
exit 1
fi
echo "All 5 binaries copied to npm package successfully"
ls -lh npm/bin/
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: 'https://registry.npmjs.org'
- name: Publish to npm
working-directory: npm
run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# deploy-coverage:
# name: Deploy Coverage to GitHub Pages
# needs: [extract-version, ci]
# if: needs.extract-version.outputs.should_release == 'true'
# runs-on: ubuntu-latest
# permissions:
# contents: write
# steps:
# - name: Download coverage artifact
# uses: actions/download-artifact@v4
# with:
# name: coverage-report
# path: coverage-report
# - name: Deploy to GitHub Pages
# uses: peaceiris/actions-gh-pages@v3
# with:
# github_token: ${{ secrets.GITHUB_TOKEN }}
# publish_dir: ./coverage-report
# publish_branch: gh-pages
# destination_dir: coverage
# keep_files: true
# enable_jekyll: false
# commit_message: 'Deploy coverage for v${{ needs.extract-version.outputs.version }}'
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}