Skip to content

Commit a761f83

Browse files
committed
refactor: consolidate CI jobs into single matrix-based workflow
Merge separate test, build, publish, and release jobs into a single matrix job that runs all steps conditionally. Tests, NPM publishing, and GitHub release creation now run only once on the linux/amd64 build to avoid duplication. Update action versions to v4/v5 and add provenance publishing for NPM.
1 parent 336c332 commit a761f83

File tree

1 file changed

+36
-64
lines changed

1 file changed

+36
-64
lines changed

.github/workflows/publish.yml

Lines changed: 36 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -10,119 +10,91 @@ permissions:
1010
id-token: write
1111

1212
jobs:
13-
tests:
13+
publish:
14+
name: Test + Build + Publish + Release
1415
runs-on: ubuntu-latest
15-
steps:
16-
- name: Checkout code
17-
uses: actions/checkout@v6.0.1
18-
19-
- name: Set up Go
20-
uses: actions/setup-go@v6.1.0
21-
with:
22-
go-version: "1.24.5"
2316

24-
- name: Run tests
25-
run: go test ./...
26-
27-
build:
28-
name: Build binaries
29-
needs: tests
30-
runs-on: ${{ matrix.os }}
3117
strategy:
3218
matrix:
3319
include:
34-
- os: ubuntu-latest
35-
goos: linux
20+
- goos: linux
3621
goarch: amd64
3722
artifact_name: opencore-linux-amd64
38-
- os: macos-latest
39-
goos: darwin
23+
- goos: darwin
4024
goarch: amd64
4125
artifact_name: opencore-darwin-amd64
42-
- os: macos-latest
43-
goos: darwin
26+
- goos: darwin
4427
goarch: arm64
4528
artifact_name: opencore-darwin-arm64
46-
- os: windows-latest
47-
goos: windows
29+
- goos: windows
4830
goarch: amd64
4931
artifact_name: opencore-windows-amd64.exe
5032

5133
steps:
52-
- name: Checkout code
53-
uses: actions/checkout@v6.0.1
34+
- name: Checkout
35+
uses: actions/checkout@v4
5436

55-
- name: Set up Go
56-
uses: actions/setup-go@v6.1.0
37+
- name: Setup Go
38+
uses: actions/setup-go@v5
5739
with:
5840
go-version: "1.24.5"
5941

60-
- name: Get dependencies
61-
run: go mod download
62-
42+
- name: Go tests
43+
if: ${{ matrix.goos == 'linux' && matrix.goarch == 'amd64' }}
44+
run: go test ./...
6345
- name: Build binary
6446
env:
6547
GOOS: ${{ matrix.goos }}
6648
GOARCH: ${{ matrix.goarch }}
6749
CGO_ENABLED: 0
6850
run: |
69-
go build -ldflags "-X main.version=${{ github.ref_name }}" -o ${{ matrix.artifact_name }} .
51+
go build -ldflags "-X main.version=${{ github.ref_name }}" -o "${{ matrix.artifact_name }}" .
7052
7153
- name: Upload artifact
7254
uses: actions/upload-artifact@v4
7355
with:
7456
name: ${{ matrix.artifact_name }}
7557
path: ${{ matrix.artifact_name }}
7658

77-
publish-npm:
78-
name: Publish to NPM
79-
needs: build
80-
runs-on: ubuntu-latest
81-
steps:
82-
- name: Checkout code
83-
uses: actions/checkout@v6.0.1
84-
85-
- name: Setup Node.js
59+
- name: Setup Node (only once)
60+
if: ${{ matrix.goos == 'linux' && matrix.goarch == 'amd64' }}
8661
uses: actions/setup-node@v4
8762
with:
88-
node-version: '24'
89-
registry-url: 'https://registry.npmjs.org'
90-
cache: pnpm
63+
node-version: "24"
9164

92-
- name: Update package version
65+
- name: Update package version (only once)
66+
if: ${{ matrix.goos == 'linux' && matrix.goarch == 'amd64' }}
9367
run: |
9468
VERSION=${GITHUB_REF#refs/tags/v}
95-
npm version $VERSION --no-git-tag-version --allow-same-version
96-
97-
- name: Publish to NPM
98-
run: npm publish
69+
npm version "$VERSION" --no-git-tag-version --allow-same-version
9970
71+
- name: Publish to NPM (OIDC Trusted Publisher) (only once)
72+
if: ${{ matrix.goos == 'linux' && matrix.goarch == 'amd64' }}
73+
env:
74+
NODE_AUTH_TOKEN: ""
75+
NPM_TOKEN: ""
76+
run: npm publish --access public --provenance
10077

101-
release:
102-
name: Create Release
103-
needs: publish-npm
104-
runs-on: ubuntu-latest
105-
steps:
106-
- name: Checkout code
107-
uses: actions/checkout@v6.0.1
108-
109-
- name: Download all artifacts
110-
uses: actions/download-artifact@v7.0.0
78+
- name: Download all artifacts (only once)
79+
if: ${{ matrix.goos == 'linux' && matrix.goarch == 'amd64' }}
80+
uses: actions/download-artifact@v4
11181
with:
11282
path: ./artifacts
11383

114-
- name: Prepare release assets
84+
- name: Prepare release assets (only once)
85+
if: ${{ matrix.goos == 'linux' && matrix.goarch == 'amd64' }}
11586
run: |
11687
mkdir -p release
117-
find ./artifacts -type f -exec cp {} ./release/ \;
88+
find ./artifacts -type f -maxdepth 2 -exec cp {} ./release/ \;
11889
ls -lah ./release/
11990
120-
- name: Create Release
121-
uses: softprops/action-gh-release@v2.5.0
91+
- name: Create Release (only once)
92+
if: ${{ matrix.goos == 'linux' && matrix.goarch == 'amd64' }}
93+
uses: softprops/action-gh-release@v2
12294
with:
12395
files: ./release/*
12496
draft: false
12597
prerelease: false
12698
body_path: RELEASE.md
12799
env:
128-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
100+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)