Skip to content

Commit 476caea

Browse files
committed
feat: add build workflow
1 parent 8f4c1e0 commit 476caea

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

.github/workflows/build.yaml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
name: Build
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
choice:
7+
type: choice
8+
required: true
9+
options:
10+
- "Artifact"
11+
- "Release"
12+
version:
13+
type: string
14+
required: false
15+
16+
jobs:
17+
build:
18+
strategy:
19+
matrix:
20+
os: [linux, windows, darwin]
21+
arch: [amd64, arm64]
22+
runs-on: ubuntu-24.04
23+
steps:
24+
- uses: actions/checkout@v4
25+
- uses: actions/setup-go@v5
26+
with:
27+
go-version: '1.24'
28+
check-latest: true
29+
- name: Build
30+
run: |
31+
go build -ldflags="-s"
32+
env:
33+
GOOS: ${{ matrix.os }}
34+
GOARCH: ${{ matrix.arch }}
35+
- uses: actions/upload-artifact@v4
36+
with:
37+
name: icns-encoder-${{ matrix.os }}-${{ matrix.arch }}
38+
path: ./icns-encoder*
39+
40+
release:
41+
if: github.event.inputs.choice == 'Release'
42+
runs-on: ubuntu-24.04
43+
needs: [build]
44+
steps:
45+
- uses: actions/download-artifact@v4
46+
with:
47+
pattern: icns-encoder-*
48+
path: artifacts
49+
- name: Rename
50+
run: |
51+
mkdir ./outputs
52+
find ./artifacts -type f | while read file; do
53+
ext="${file##*.}"
54+
artifact_name=$(basename "$(dirname "$file")")
55+
[ "$ext" != "$file" ] && new_name="$artifact_name.$ext" || new_name="$artifact_name"
56+
mv "$file" "./outputs/$new_name"
57+
done
58+
- uses: softprops/action-gh-release@v2
59+
with:
60+
name: Release ${{ github.event.inputs.version }}
61+
tag_name: ${{ github.event.inputs.version }}
62+
files: |
63+
./outputs/*

0 commit comments

Comments
 (0)