-
Notifications
You must be signed in to change notification settings - Fork 10
85 lines (71 loc) · 2.39 KB
/
binary-build.yml
File metadata and controls
85 lines (71 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Build Binary
on:
push:
branches: [ main ]
permissions:
contents: write
packages: write
jobs:
check-commit:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.version.outputs.new_version }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Determine Version
id: version
run: |
# Get the latest version tag, default to v0 if none exists
LATEST_TAG=$(gh release list -L 1 | cut -f 1 | sed 's/Release //' || echo "v0")
LATEST_TAG=${LATEST_TAG:-v0}
# Extract current version numbers
VERSION=$(echo $LATEST_TAG | sed 's/v//')
NEW_VERSION="v$((VERSION + 1))"
echo "Previous version: $LATEST_TAG"
echo "New version: $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ github.token }}
- name: Create Release
run: |
gh release create "${{ steps.version.outputs.new_version }}" \
--title "Release ${{ steps.version.outputs.new_version }}" \
--draft \
--notes "Local Content Share latest release binaries." \
--target ${{ github.sha }}
env:
GH_TOKEN: ${{ github.token }}
build:
needs: check-commit
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux, windows, darwin]
arch: [amd64, arm64]
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
- name: Build Binary
run: |
GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -ldflags="-s -w" -o local-content-share-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.os == 'windows' && '.exe' || '' }}
- name: Upload Release Asset
run: |
gh release upload "${{ needs.check-commit.outputs.version }}" \
"local-content-share-${{ matrix.os }}-${{ matrix.arch }}${{ matrix.os == 'windows' && '.exe' || '' }}"
env:
GH_TOKEN: ${{ github.token }}
publish:
needs: [check-commit, build]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Publish Release
run: |
gh release edit "${{ needs.check-commit.outputs.version }}" --draft=false
env:
GH_TOKEN: ${{ github.token }}