Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 98352f7

Browse files
Enhance release workflow with multi-platform builds
Added a build job for multiple platforms and updated dependencies installation.
1 parent 10e0e1e commit 98352f7

1 file changed

Lines changed: 60 additions & 15 deletions

File tree

.github/workflows/release.yml

Lines changed: 60 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,16 @@ on:
66
- 'v*' # triggers on version tags like v0.1.0, v1.2.3
77

88
permissions:
9-
contents: write
9+
contents: write
1010

1111
jobs:
12+
# ── 1. Create the GitHub release object first ─────────────────────────────
1213
release:
1314
runs-on: ubuntu-latest
14-
1515
steps:
1616
- name: Checkout Code
1717
uses: actions/checkout@v4
1818

19-
- name: Install Linux dependencies
20-
run: |
21-
sudo apt update
22-
sudo apt install -y libx11-dev
23-
2419
- name: Set up Go
2520
uses: actions/setup-go@v4
2621
with:
@@ -29,14 +24,6 @@ jobs:
2924
- name: Download Dependencies
3025
run: go mod tidy
3126

32-
- name: Build Binary
33-
run: |
34-
echo "Building reposcan ${VERSION} ..."
35-
go build -o reposcan .
36-
37-
- name: Verify Version
38-
run: ./reposcan version
39-
4027
- name: Trigger pkg.go.dev indexing
4128
run: |
4229
REPO="${{ github.repository }}"
@@ -51,4 +38,62 @@ jobs:
5138
body_path: docs/release-notes/${{ github.ref_name }}.md
5239
generate_release_notes: false
5340

41+
# ── 2. Build binaries for each platform and attach to the release ─────────
42+
build:
43+
needs: release
44+
strategy:
45+
matrix:
46+
include:
47+
- os: linux
48+
arch: amd64
49+
runner: ubuntu-latest
50+
- os: darwin
51+
arch: amd64
52+
runner: macos-latest
53+
- os: darwin
54+
arch: arm64
55+
runner: macos-latest
56+
57+
runs-on: ${{ matrix.runner }}
58+
59+
steps:
60+
- name: Checkout Code
61+
uses: actions/checkout@v4
62+
63+
- name: Install Linux dependencies
64+
if: matrix.os == 'linux'
65+
run: |
66+
sudo apt update
67+
sudo apt install -y xvfb libx11-dev x11-utils
68+
69+
- name: Set up Go
70+
uses: actions/setup-go@v4
71+
with:
72+
go-version: '1.24.x'
73+
74+
- name: Download Dependencies
75+
run: go mod tidy
5476

77+
- name: Build Binary
78+
env:
79+
GOOS: ${{ matrix.os }}
80+
GOARCH: ${{ matrix.arch }}
81+
CGO_ENABLED: 1
82+
run: |
83+
ASSET_NAME="reposcan-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.arch }}"
84+
echo "Building $ASSET_NAME ..."
85+
go build \
86+
-ldflags "-X main.mixpanelToken=${{ secrets.MIXPANEL_TOKEN }}" \
87+
-o "$ASSET_NAME" \
88+
.
89+
90+
- name: Verify Binary
91+
if: matrix.os != 'linux' || matrix.arch != 'arm64'
92+
run: ./reposcan-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.arch }} version
93+
94+
- name: Upload Binary to Release
95+
uses: softprops/action-gh-release@v2
96+
with:
97+
tag_name: ${{ github.ref_name }}
98+
token: ${{ secrets.GITHUB_TOKEN }}
99+
files: reposcan-${{ github.ref_name }}-${{ matrix.os }}-${{ matrix.arch }}

0 commit comments

Comments
 (0)