Skip to content

Commit 82bf20a

Browse files
committed
Refactor GitHub Actions workflow for release process: streamline jobs, update Go version, and build for multiple platforms. Remove unnecessary steps and improve artifact handling.
1 parent 7630c01 commit 82bf20a

File tree

1 file changed

+34
-45
lines changed

1 file changed

+34
-45
lines changed

.github/workflows/release.yml

Lines changed: 34 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,65 +3,54 @@ name: Release
33
on:
44
push:
55
tags:
6-
- 'v*' # Trigger on version tags
6+
- 'v*'
77

88
jobs:
99
release:
10-
strategy:
11-
matrix:
12-
os: [ubuntu-latest, windows-latest, macos-latest]
13-
runs-on: ${{ matrix.os }}
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
issues: write
14+
pull-requests: write
1415
steps:
15-
- uses: actions/checkout@v4
16+
- name: Checkout Repository
17+
uses: actions/checkout@v4
1618
with:
1719
fetch-depth: 0
1820

1921
- name: Set up Go
20-
uses: actions/setup-go@v5
21-
with:
22-
go-version: '1.21.x'
23-
24-
- name: Install dependencies
25-
run: go mod download
26-
27-
- name: Run tests
28-
run: go test -v ./...
29-
30-
- name: Build
31-
env:
32-
GOOS: ${{ matrix.os == 'windows-latest' && 'windows' || matrix.os == 'macos-latest' && 'darwin' || 'linux' }}
33-
GOARCH: amd64
34-
run: go build -v -o cpp2py ./cmd/cpp2py
35-
36-
- name: Upload artifact
37-
uses: actions/upload-artifact@v4
22+
uses: actions/setup-go@v4
3823
with:
39-
name: cpp2py-${{ matrix.os }}
40-
path: cpp2py
41-
42-
create-release:
43-
needs: release
44-
runs-on: ubuntu-latest
45-
steps:
46-
- uses: actions/checkout@v4
47-
with:
48-
fetch-depth: 0
49-
50-
- name: Download artifacts
51-
uses: actions/download-artifact@v4
24+
go-version: '1.23'
25+
26+
- name: Build for Multiple Platforms
27+
run: |
28+
mkdir -p releases
29+
PLATFORMS=("windows/amd64" "linux/amd64" "linux/arm64" "darwin/amd64" "darwin/arm64")
30+
for platform in "${PLATFORMS[@]}"; do
31+
OS=${platform%/*}
32+
ARCH=${platform#*/}
33+
output_name="releases/cp2p-${OS}-${ARCH}"
34+
if [ $OS = "windows" ]; then
35+
output_name="$output_name.exe"
36+
fi
37+
GOOS=$OS GOARCH=$ARCH go build -o "$output_name" .
38+
done
39+
40+
- name: Generate Next Version
41+
id: semver
42+
uses: mathieudutour/github-tag-action@v6.1
5243
with:
53-
path: artifacts
54-
pattern: cpp2py-*
44+
github_token: ${{ secrets.GITHUB_TOKEN }}
45+
dry_run: true
5546

5647
- name: Create Release
5748
uses: softprops/action-gh-release@v1
5849
with:
50+
tag_name: ${{ steps.semver.outputs.new_tag }}
51+
name: Release ${{ steps.semver.outputs.new_tag }}
52+
body: ${{ steps.semver.outputs.changelog }}
5953
files: |
60-
artifacts/cpp2py-ubuntu-latest
61-
artifacts/cpp2py-windows-latest
62-
artifacts/cpp2py-macos-latest
63-
draft: false
64-
prerelease: false
65-
generate_release_notes: true
54+
releases/*
6655
env:
6756
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)