Skip to content

Commit 965782f

Browse files
committed
Update: Upgrade Go to 1.23 and streamline CI/CD workflow
This commit updates the Go version used in the CI/CD pipeline from 1.22 to 1.23, which should bring performance improvements and new features. Additionally, the workflow has been streamlined by reorganizing the job structure, renaming jobs for clarity, and optimizing the artifact handling and packaging process. The release job now depends on the new 'package' job, ensuring that binaries are properly packaged before release creation.
1 parent 49cb389 commit 965782f

File tree

1 file changed

+62
-72
lines changed

1 file changed

+62
-72
lines changed

.github/workflows/build-and-release.yml

Lines changed: 62 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ jobs:
6868
- name: Set up Go
6969
uses: actions/setup-go@v5
7070
with:
71-
go-version: '1.22' # Use the appropriate Go version for your project
71+
go-version: '1.23' # Use the appropriate Go version for your project
7272

7373
- name: Get dependencies
7474
run: go mod download
@@ -88,108 +88,98 @@ jobs:
8888
name: ${{ matrix.asset_name }}
8989
path: ${{ matrix.artifact_name }}
9090

91-
release:
92-
name: Create Release
91+
package:
92+
name: Package Binaries
9393
needs: [auto-tag, build]
94-
# Run if a tag was created by auto-tag or this is a tag push
95-
if: (needs.auto-tag.outputs.new_tag != '') || (github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
9694
runs-on: ubuntu-latest
97-
permissions:
98-
contents: write
95+
# Always run after build
96+
if: always() && needs.build.result == 'success'
9997
steps:
10098
- name: Checkout code
10199
uses: actions/checkout@v4
102100

103-
- name: Download all artifacts
104-
uses: actions/download-artifact@v4
105-
106-
- name: Debug info
107-
run: |
108-
echo "GitHub ref: ${{ github.ref }}"
109-
echo "Event name: ${{ github.event_name }}"
110-
echo "New tag: ${{ needs.auto-tag.outputs.new_tag }}"
111-
echo "Directory contents:"
112-
find . -type f | sort
113-
114-
- name: Create Release
115-
id: create_release
116-
uses: softprops/action-gh-release@v1
117-
env:
118-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
119-
with:
120-
tag_name: ${{ needs.auto-tag.outputs.new_tag != '' && needs.auto-tag.outputs.new_tag || github.ref_name }}
121-
name: Release ${{ needs.auto-tag.outputs.new_tag != '' && needs.auto-tag.outputs.new_tag || github.ref_name }}
122-
files: |
123-
./commit-linux-amd64/commit
124-
./commit-windows-amd64.exe/commit.exe
125-
./commit-macos-amd64/commit
126-
draft: false
127-
prerelease: false
128-
generate_release_notes: true
129-
130-
publish:
131-
name: Publish to GitHub Packages
132-
needs: [auto-tag, build]
133-
# Run if a tag was created by auto-tag or this is a tag push
134-
if: (needs.auto-tag.outputs.new_tag != '') || (github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
135-
runs-on: ubuntu-latest
136-
permissions:
137-
contents: write
138-
steps:
139-
- name: Checkout code
140-
uses: actions/checkout@v4
141-
142-
- name: Download Linux artifact
101+
- name: Download Linux Binary
143102
uses: actions/download-artifact@v4
144103
with:
145104
name: commit-linux-amd64
146-
path: ./dist/linux-amd64
105+
path: ./binaries/linux
147106

148-
- name: Download Windows artifact
107+
- name: Download Windows Binary
149108
uses: actions/download-artifact@v4
150109
with:
151110
name: commit-windows-amd64.exe
152-
path: ./dist/windows-amd64
111+
path: ./binaries/windows
153112

154-
- name: Download macOS artifact
113+
- name: Download macOS Binary
155114
uses: actions/download-artifact@v4
156115
with:
157116
name: commit-macos-amd64
158-
path: ./dist/darwin-amd64
117+
path: ./binaries/macos
159118

160-
- name: Debug info
119+
- name: Show downloaded files
161120
run: |
162-
echo "Directory contents:"
163-
find ./dist -type f | sort
164-
121+
find ./binaries -type f
122+
165123
- name: Make binaries executable
166124
run: |
167-
chmod +x ./dist/linux-amd64/commit || echo "Linux binary not found"
168-
chmod +x ./dist/darwin-amd64/commit || echo "macOS binary not found"
125+
chmod +x ./binaries/linux/commit
126+
chmod +x ./binaries/macos/commit
169127
170-
- name: Prepare release assets
128+
- name: Create packages
171129
run: |
172-
mkdir -p ./release
130+
mkdir -p ./packages
173131
174-
# Linux package
175-
tar -C ./dist/linux-amd64 -czf ./release/commit-linux-amd64.tar.gz commit || echo "Failed to create Linux package"
132+
# Package Linux binary
133+
tar -C ./binaries/linux -czf ./packages/commit-linux-amd64.tar.gz commit
176134
177-
# Windows package
178-
zip -j ./release/commit-windows-amd64.zip ./dist/windows-amd64/commit.exe || echo "Failed to create Windows package"
135+
# Package Windows binary
136+
zip -j ./packages/commit-windows-amd64.zip ./binaries/windows/commit.exe
179137
180-
# macOS package
181-
tar -C ./dist/darwin-amd64 -czf ./release/commit-macos-amd64.tar.gz commit || echo "Failed to create macOS package"
138+
# Package macOS binary
139+
tar -C ./binaries/macos -czf ./packages/commit-macos-amd64.tar.gz commit
182140
183-
echo "Release packages:"
184-
ls -la ./release/
141+
# List created packages
142+
ls -la ./packages/
143+
144+
- name: Upload packages as artifacts
145+
uses: actions/upload-artifact@v4
146+
with:
147+
name: release-packages
148+
path: ./packages/*
149+
150+
release:
151+
name: Create Release
152+
needs: [auto-tag, build, package]
153+
# Run if a tag was created by auto-tag or this is a tag push
154+
if: (needs.auto-tag.outputs.new_tag != '') || (github.event_name == 'push' && contains(github.ref, 'refs/tags/'))
155+
runs-on: ubuntu-latest
156+
permissions:
157+
contents: write
158+
steps:
159+
- name: Checkout code
160+
uses: actions/checkout@v4
185161

186-
- name: Upload release packages to GitHub Releases
162+
- name: Download packages
163+
uses: actions/download-artifact@v4
164+
with:
165+
name: release-packages
166+
path: ./packages
167+
168+
- name: List package files
169+
run: |
170+
ls -la ./packages/
171+
172+
- name: Create GitHub Release
187173
uses: softprops/action-gh-release@v1
188174
env:
189175
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
190176
with:
191177
tag_name: ${{ needs.auto-tag.outputs.new_tag != '' && needs.auto-tag.outputs.new_tag || github.ref_name }}
178+
name: Release ${{ needs.auto-tag.outputs.new_tag != '' && needs.auto-tag.outputs.new_tag || github.ref_name }}
192179
files: |
193-
./release/commit-linux-amd64.tar.gz
194-
./release/commit-windows-amd64.zip
195-
./release/commit-macos-amd64.tar.gz
180+
./packages/commit-linux-amd64.tar.gz
181+
./packages/commit-windows-amd64.zip
182+
./packages/commit-macos-amd64.tar.gz
183+
draft: false
184+
prerelease: false
185+
generate_release_notes: true

0 commit comments

Comments
 (0)