Skip to content

Commit 6f46eef

Browse files
authored
chore(ci): split build and publish in different jobs (#132)
1 parent 09f820e commit 6f46eef

File tree

2 files changed

+156
-16
lines changed

2 files changed

+156
-16
lines changed

.github/actions/setup-go/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ runs:
2222
- name: Go cache
2323
uses: actions/[email protected]
2424
with:
25-
key: setup-go-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum') }}-${{ github.workflow }}-${{ inputs.cache-name }}
25+
key: setup-go-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ inputs.cache-name }}-${{ hashFiles('**/go.sum') }}
2626
restore-keys: |
27-
setup-go-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ hashFiles('**/go.sum') }}-${{ github.workflow }}-
27+
setup-go-${{ runner.os }}-${{ steps.install-go.outputs.go-version }}-${{ inputs.cache-name }}-${{ hashFiles('**/go.sum') }}
2828
path: |
2929
~/go/pkg/mod
3030
~/.cache/go-build

.github/workflows/release.yml

Lines changed: 154 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,20 @@ env:
4040
GO_VERSION: '1.24.1'
4141

4242
jobs:
43-
publish:
44-
name: Build
45-
env:
46-
release_npm: ${{ inputs.to_release == 'all' || inputs.to_release == 'npm' }}
47-
release_extension: ${{ inputs.to_release == 'all' || inputs.to_release == 'extension' }}
48-
runs-on: ubuntu-latest
43+
check:
44+
name: Test
45+
needs: build
46+
strategy:
47+
fail-fast: true
48+
matrix:
49+
include:
50+
- goos: linux
51+
goarch: amd64
52+
runs_on: ubuntu-latest
53+
node_arch: x64
54+
node_os: linux
55+
56+
runs-on: ${{ matrix.runs_on }}
4957
steps:
5058
- name: Checkout
5159
uses: actions/checkout@v4
@@ -63,38 +71,92 @@ jobs:
6371
uses: ./.github/actions/setup-go
6472
with:
6573
go-version: ${{ env.GO_VERSION }}
66-
cache-name: release-go
74+
cache-name: ${{ matrix.node_os }}-${{ matrix.node_arch }}
6775

6876
- name: Install pnpm
6977
run: corepack enable
7078

7179
- name: Install dependencies
7280
run: pnpm install --frozen-lockfile
7381

82+
- name: Download Artifact
83+
uses: actions/[email protected]
84+
with:
85+
path: binaries
86+
87+
- name: Move binaries
88+
run: |
89+
find ./binaries
90+
for file in binaries/*/*-rslint; do
91+
echo "Processing $file"
92+
filename=$(basename "$file")
93+
dirname="${filename%-rslint}"
94+
target_dir="npm/$dirname"
95+
mkdir -p "$target_dir"
96+
echo "Copy $file to $target_dir/rslint"
97+
cp "$file" "npm/$dirname/rslint"
98+
done
99+
find ./npm
100+
74101
- name: Format code
75102
run: pnpm format:check
76103

77-
- name: Build packages
78-
run: pnpm build
104+
- name: Build
105+
run: pnpm run build
106+
79107
- name: TypeCheck
80108
run: pnpm typecheck
109+
81110
- name: Lint code
82111
run: pnpm lint
83112
- name: Test on Linux
84-
if: runner.os == 'Linux'
85113
run: xvfb-run -a pnpm -r test
86114

115+
publish:
116+
name: Publish
117+
needs: [build, check]
118+
env:
119+
release_npm: ${{ inputs.to_release == 'all' || inputs.to_release == 'npm' }}
120+
release_extension: ${{ inputs.to_release == 'all' || inputs.to_release == 'extension' }}
121+
runs-on: ubuntu-latest
122+
steps:
123+
- name: Checkout
124+
uses: actions/checkout@v4
125+
with:
126+
fetch-depth: 1
127+
ref: ${{ github.event.inputs.branch }}
128+
submodules: true
129+
130+
- name: Setup Node.js
131+
uses: actions/setup-node@v4
132+
with:
133+
node-version: '24'
134+
135+
- name: Setup Go
136+
uses: ./.github/actions/setup-go
137+
with:
138+
go-version: ${{ env.GO_VERSION }}
139+
cache-name: linux-x86
140+
141+
- name: Install pnpm
142+
run: corepack enable
143+
144+
- name: Install dependencies
145+
run: pnpm install --frozen-lockfile
146+
147+
- name: Format code
148+
run: pnpm format:check
149+
87150
- name: Publish npm packages
88151
if: env.release_npm == 'true'
89152
env:
90153
NPM_TOKEN: ${{ secrets.RSLINT_NPM_TOKEN }}
91154
run: |
92155
npm config set "//registry.npmjs.org/:_authToken" "${NPM_TOKEN}"
93-
pnpm build:npm
94-
pnpm -r publish --tag ${{ github.event.inputs.npm_tag }} --publish-branch ${{ github.event.inputs.branch }}
156+
pnpm -r publish --dry-run --tag ${{ github.event.inputs.npm_tag }} --publish-branch ${{ github.event.inputs.branch }}
95157
96158
- name: Build and publish to Microsoft VS Code Marketplace
97-
if: env.release_extension == 'true'
159+
if: false
98160
env:
99161
VSCE_PAT: ${{ secrets.RSLINT_VSCE_PAT }}
100162
run: |
@@ -105,7 +167,7 @@ jobs:
105167
fi
106168
107169
- name: Build and publish to Open VSX Registry
108-
if: env.release_extension == 'true'
170+
if: false
109171
env:
110172
OVSX_PAT: ${{ secrets.RSLINT_OVSX_PAT }}
111173
run: |
@@ -114,3 +176,81 @@ jobs:
114176
else
115177
pnpm publish:ovsx
116178
fi
179+
180+
build:
181+
name: Build-Binaries
182+
strategy:
183+
fail-fast: false
184+
matrix:
185+
include:
186+
- goos: darwin
187+
runs_on: macos-13
188+
goarch: amd64
189+
node_arch: x64
190+
node_os: darwin
191+
- goos: darwin
192+
runs_on: macos-latest
193+
goarch: arm64
194+
node_arch: arm64
195+
node_os: darwin
196+
- goos: linux
197+
goarch: amd64
198+
runs_on: ubuntu-latest
199+
node_arch: x64
200+
node_os: linux
201+
- goos: linux
202+
runs_on: ubuntu-latest
203+
goarch: arm64
204+
node_arch: arm64
205+
node_os: linux
206+
- goos: windows
207+
goarch: amd64
208+
node_arch: x64
209+
node_os: win32
210+
runs_on: windows-latest
211+
- goos: windows
212+
goarch: arm64
213+
node_arch: arm64
214+
node_os: win32
215+
runs_on: windows-latest
216+
runs-on: ${{ matrix.runs_on }}
217+
steps:
218+
- name: Checkout
219+
uses: actions/checkout@v4
220+
with:
221+
fetch-depth: 1
222+
ref: ${{ github.event.inputs.branch }}
223+
submodules: true
224+
225+
- name: Setup Node.js
226+
uses: actions/setup-node@v4
227+
with:
228+
node-version: '24'
229+
230+
- name: Setup Go
231+
uses: ./.github/actions/setup-go
232+
with:
233+
go-version: ${{ env.GO_VERSION }}
234+
cache-name: ${{ matrix.node_os }}-${{ matrix.node_arch }}
235+
236+
- name: Install pnpm
237+
run: corepack enable
238+
239+
- name: Install dependencies
240+
run: pnpm install --frozen-lockfile
241+
242+
- name: Go Build packages
243+
if: matrix.node_os != 'win32'
244+
run: |
245+
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o ${{ matrix.node_os }}-${{ matrix.node_arch }}-rslint ./cmd/rslint
246+
247+
- name: Go Build Packages (windows)
248+
if: matrix.node_os == 'win32'
249+
run: |
250+
$env:GOOS="${{ matrix.goos }}"; $env:GOARCH="${{ matrix.goarch }}"; go build -o ${{ matrix.node_os }}-${{ matrix.node_arch }}-rslint ./cmd/rslint
251+
252+
- name: Upload artifact
253+
uses: actions/upload-artifact@v4
254+
with:
255+
name: ${{ matrix.node_os }}-${{ matrix.node_arch }}-rslint
256+
path: ${{ matrix.node_os }}-${{ matrix.node_arch }}-rslint

0 commit comments

Comments
 (0)