Skip to content

Commit 062416a

Browse files
committed
add github workflow file
1 parent ac096d9 commit 062416a

File tree

1 file changed

+61
-0
lines changed

1 file changed

+61
-0
lines changed

.github/workflows/release.yaml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Cross-platform Build and Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags like v1.0.0
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
strategy:
12+
matrix:
13+
goos: [linux, windows, darwin]
14+
goarch: [amd64]
15+
name: Build ${{ matrix.goos }}-${{ matrix.goarch }}
16+
17+
steps:
18+
- name: Checkout source
19+
uses: actions/checkout@v3
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v4
23+
with:
24+
go-version: '1.24.2'
25+
26+
- name: Build binary from pmcompose.go
27+
run: |
28+
mkdir -p build/${{ matrix.goos }}_${{ matrix.goarch }}
29+
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} go build -o build/${{ matrix.goos }}_${{ matrix.goarch }}/pmcompose${{ matrix.goos == 'windows' && '.exe' || '' }} pmcompose.go
30+
31+
- name: Copy template files
32+
run: |
33+
cp -r pmcompose_templates build/${{ matrix.goos }}_${{ matrix.goarch }}/
34+
35+
- name: Create ZIP archive
36+
run: |
37+
cd build/${{ matrix.goos }}_${{ matrix.goarch }}
38+
zip -r ../../pmcompose_${{ matrix.goos }}_${{ matrix.goarch }}.zip .
39+
cd ../..
40+
41+
- name: Upload build artifact
42+
uses: actions/upload-artifact@v4
43+
with:
44+
name: pmcompose_${{ matrix.goos }}_${{ matrix.goarch }}
45+
path: pmcompose_${{ matrix.goos }}_${{ matrix.goarch }}.zip
46+
47+
release:
48+
needs: build
49+
runs-on: ubuntu-latest
50+
steps:
51+
- name: Download all artifacts
52+
uses: actions/download-artifact@v4
53+
with:
54+
path: artifacts
55+
56+
- name: Create GitHub Release
57+
uses: softprops/action-gh-release@v2
58+
with:
59+
files: artifacts/**/*.zip
60+
env:
61+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)