Skip to content

Commit ab5d117

Browse files
committed
Release workflow updated to use GitHub's release asset upload feature
1 parent 8e23c5e commit ab5d117

2 files changed

Lines changed: 36 additions & 41 deletions

File tree

.github/workflows/release.yml

Lines changed: 35 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,57 @@
1-
name: Build and Release
1+
name: Release
22

33
on:
44
push:
55
tags:
6-
- 'v*.*.*' # e.g. v1.1.1, v2.0.0
6+
- 'v*.*.*' # Matches tags like v1.1.1 or v2.0.0
77

88
jobs:
99
build:
10+
name: Build & Release Binaries
1011
runs-on: ubuntu-latest
11-
strategy:
12-
matrix:
13-
os: [linux, macos, windows]
14-
arch: [amd64]
12+
13+
permissions:
14+
contents: write # Required to upload release assets
1515

1616
steps:
17-
- name: Checkout code
18-
uses: actions/checkout@v3
17+
- name: ⬇️ Checkout code
18+
uses: actions/checkout@v4
1919

20-
- name: Set up Go
21-
uses: actions/setup-go@v4
20+
- name: 🛠️ Set up Go
21+
uses: actions/setup-go@v5
2222
with:
23-
go-version: '1.20'
23+
go-version: '1.21'
24+
25+
- name: 🧼 Clean previous builds
26+
run: rm -rf dist && mkdir dist
2427

25-
- name: Build binary
28+
- name: 📦 Build for Linux
2629
run: |
27-
mkdir -p dist/${{ matrix.os }}
28-
if [[ "${{ matrix.os }}" == "linux" ]]; then
29-
GOOS=linux GOARCH=${{ matrix.arch }} CGO_ENABLED=0 \
30-
go build -ldflags="-s -w" -o dist/linux/smartcommit-linux .
31-
elif [[ "${{ matrix.os }}" == "macos" ]]; then
32-
GOOS=darwin GOARCH=${{ matrix.arch }} CGO_ENABLED=0 \
33-
go build -ldflags="-s -w" -o dist/macos/smartcommit-macos .
34-
else
35-
GOOS=windows GOARCH=${{ matrix.arch }} CGO_ENABLED=0 \
36-
go build -ldflags="-s -w" -o dist/windows/smartcommit-windows.exe .
37-
fi
30+
VERSION=${GITHUB_REF#refs/tags/}
31+
GOOS=linux GOARCH=amd64 go build -ldflags "-X 'smartcommit/cmd.version=${VERSION}'" -o dist/smartcommit-linux
3832
39-
- name: Package archives
33+
- name: 📦 Build for macOS
4034
run: |
41-
if [[ "${{ matrix.os }}" == "linux" ]]; then
42-
tar -czvf dist/smartcommit-linux.tar.gz -C dist/linux smartcommit-linux
43-
elif [[ "${{ matrix.os }}" == "macos" ]]; then
44-
tar -czvf dist/smartcommit-macos.tar.gz -C dist/macos smartcommit-macos
45-
else
46-
tar -czvf dist/smartcommit-windows.tar.gz -C dist/windows smartcommit-windows.exe
47-
fi
35+
VERSION=${GITHUB_REF#refs/tags/}
36+
GOOS=darwin GOARCH=amd64 go build -ldflags "-X 'smartcommit/cmd.version=${VERSION}'" -o dist/smartcommit-macos
4837
49-
- name: Create GitHub Release
50-
id: create_release
51-
uses: softprops/action-gh-release@v1
52-
with:
53-
tag_name: ${{ github.ref_name }}
54-
env:
55-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
- name: 📦 Build for Windows
39+
run: |
40+
VERSION=${GITHUB_REF#refs/tags/}
41+
GOOS=windows GOARCH=amd64 go build -ldflags "-X 'smartcommit/cmd.version=${VERSION}'" -o dist/smartcommit-windows.exe
5642
57-
- name: Upload Release Assets
58-
uses: softprops/action-gh-release@v1
43+
- name: 📚 Package binaries
44+
run: |
45+
cd dist
46+
tar -czf smartcommit-linux.tar.gz smartcommit-linux
47+
tar -czf smartcommit-macos.tar.gz smartcommit-macos
48+
tar -czf smartcommit-windows.tar.gz smartcommit-windows.exe
49+
50+
- name: 🚀 Create GitHub Release and Upload Assets
51+
uses: softprops/action-gh-release@v2
5952
with:
53+
name: ${{ github.ref_name }}
54+
tag_name: ${{ github.ref_name }}
6055
files: |
6156
dist/smartcommit-linux.tar.gz
6257
dist/smartcommit-macos.tar.gz

cmd/root.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import (
66
"github.com/spf13/cobra"
77
)
88

9-
const version = "v1.1.1"
9+
var version = "dev"
1010

1111
var rootCmd = &cobra.Command{
1212
Use: "smartcommit",

0 commit comments

Comments
 (0)