Skip to content

Commit 9d65df4

Browse files
committed
Refactor release workflow to streamline release process and improve version handling
1 parent 3a6d17a commit 9d65df4

File tree

1 file changed

+49
-17
lines changed

1 file changed

+49
-17
lines changed

.github/workflows/release.yml

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,21 @@ on:
55
workflows: ["CI"]
66
types:
77
- completed
8-
push:
9-
tags:
10-
- v*
8+
branches:
9+
- release
10+
# Also allow manual triggering for releases
11+
workflow_dispatch:
1112

1213
permissions:
1314
contents: write
15+
issues: write
16+
pull-requests: write
1417

1518
jobs:
1619
release:
17-
if: |
18-
(github.event.workflow_run.conclusion == 'success' && github.event_name == 'workflow_run') ||
19-
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v'))
20+
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
2021
runs-on: ubuntu-latest
21-
permissions:
22-
contents: write
23-
issues: write
24-
pull-requests: write
22+
2523
steps:
2624
- name: Checkout Repository
2725
uses: actions/checkout@v4
@@ -31,21 +29,28 @@ jobs:
3129
- name: Set up Go
3230
uses: actions/setup-go@v4
3331
with:
34-
go-version: '1.23'
32+
go-version: '1.21'
3533

3634
- name: Build for Multiple Platforms
35+
working-directory: ./
3736
run: |
38-
mkdir -p releases
39-
PLATFORMS=("windows/amd64" "linux/amd64" "darwin/amd64" "darwin/arm64")
37+
mkdir -p ../releases
38+
39+
# Build for different platforms
40+
PLATFORMS=("windows/amd64" "linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64")
4041
for platform in "${PLATFORMS[@]}"; do
4142
OS=${platform%/*}
4243
ARCH=${platform#*/}
43-
output_name="releases/squirrelzip-${OS}-${ARCH}"
44+
output_name="../releases/sq-${OS}-${ARCH}"
4445
if [ $OS = "windows" ]; then
4546
output_name="$output_name.exe"
4647
fi
47-
GOOS=$OS GOARCH=$ARCH go build -o "$output_name" .
48+
echo "Building for $OS/$ARCH..."
49+
GOOS=$OS GOARCH=$ARCH go build -ldflags="-s -w" -o "$output_name" .
4850
done
51+
52+
# Make binaries executable
53+
chmod +x ../releases/sq-*
4954
5055
- name: Generate Next Version
5156
id: semver
@@ -54,12 +59,39 @@ jobs:
5459
github_token: ${{ secrets.GITHUB_TOKEN }}
5560
dry_run: true
5661

62+
- name: Check if release already exists
63+
id: check_release
64+
run: |
65+
VERSION="${{ steps.semver.outputs.new_tag }}"
66+
if gh release view "$VERSION" >/dev/null 2>&1; then
67+
echo "Release $VERSION already exists, skipping..."
68+
echo "skip=true" >> $GITHUB_OUTPUT
69+
else
70+
echo "skip=false" >> $GITHUB_OUTPUT
71+
fi
72+
env:
73+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
74+
5775
- name: Create Release
76+
if: steps.check_release.outputs.skip == 'false' && steps.semver.outputs.new_tag != ''
5877
uses: softprops/action-gh-release@v1
5978
with:
6079
tag_name: ${{ steps.semver.outputs.new_tag }}
61-
name: Release ${{ steps.semver.outputs.new_tag }}
62-
body: ${{ steps.semver.outputs.changelog }}
80+
name: "Squirrel Zip ${{ steps.semver.outputs.new_tag }}"
81+
body: |
82+
## What's Changed
83+
84+
${{ steps.semver.outputs.changelog }}
85+
86+
## Downloads
87+
88+
Download the appropriate binary for your platform:
89+
- **Linux (x64)**: sq-linux-amd64
90+
- **Linux (ARM64)**: sq-linux-arm64
91+
- **Windows (x64)**: sq-windows-amd64.exe
92+
- **macOS (Intel)**: sq-darwin-amd64
93+
- **macOS (Apple Silicon)**: sq-darwin-arm64
94+
```
6395
files: |
6496
releases/*
6597
env:

0 commit comments

Comments
 (0)