-
Notifications
You must be signed in to change notification settings - Fork 2.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(ci): upload built binaries to GitHub Releases on tag creation #810
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,14 +2,18 @@ name: Go Build and Release | |
|
||
on: | ||
push: | ||
branches: [ "main" ] | ||
branches: ["main"] | ||
tags: | ||
- "v*" | ||
pull_request: | ||
branches: [ "main" ] | ||
branches: ["main"] | ||
|
||
jobs: | ||
build: | ||
name: Build binaries for Windows, macOS, and Linux | ||
runs-on: ${{ matrix.os }} | ||
permissions: | ||
contents: write | ||
strategy: | ||
matrix: | ||
os: [ubuntu-latest, macos-latest, windows-latest] | ||
|
@@ -20,32 +24,36 @@ jobs: | |
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
uses: actions/checkout@v4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use a new Checkout action |
||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.22.1' | ||
go-version-file: ./go.mod | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Stop maintaining the Go version in two places. |
||
|
||
- name: Build binary on Linux and macOS | ||
if: matrix.os != 'windows-latest' | ||
env: | ||
OS: ${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rebrand the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. strongly suggest removing the "put inside dmg" step on macos/darwin while you're at it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I'm not on the project, or involved in any way, I don't want to remove any functionality in this PR. That's a decision for the maintainers. I have, however, updated the pipeline to keep the MacOS binary around as well as the dmg in 3b35d88. |
||
GOOS: ${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }} | ||
GOARCH: ${{ matrix.arch }} | ||
run: | | ||
GOOS=${{ matrix.os == 'ubuntu-latest' && 'linux' || 'darwin' }} \ | ||
GOARCH=${{ matrix.arch }} \ | ||
go build -o fabric-${{ matrix.os }}-${{ matrix.arch }}-${{ github.ref_name }} . | ||
go build -o fabric-${OS}-${{ matrix.arch }}-${{ github.ref_name }} . | ||
|
||
- name: Build binary on Windows | ||
if: matrix.os == 'windows-latest' | ||
env: | ||
OS: windows | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Rebrand the |
||
GOOS: windows | ||
GOARCH: ${{ matrix.arch }} | ||
run: | | ||
$env:GOOS = 'windows' | ||
$env:GOARCH = '${{ matrix.arch }}' | ||
go build -o fabric-${{ matrix.os }}-${{ matrix.arch }}-${{ github.ref_name }} . | ||
go build -o fabric-${OS}-${{ matrix.arch }}-${{ github.ref_name }} . | ||
|
||
- name: Create DMG for macOS | ||
if: matrix.os == 'macos-latest' | ||
run: | | ||
mkdir dist | ||
mv fabric-macos-latest-${{ matrix.arch }}-${{ github.ref_name }} dist/fabric | ||
cp fabric-macos-latest-${{ matrix.arch }}-${{ github.ref_name }} dist/fabric | ||
hdiutil create dist/fabric-${{ matrix.arch }}.dmg -volname "fabric" -srcfolder dist/fabric | ||
mv dist/fabric-${{ matrix.arch }}.dmg fabric-macos-${{ matrix.arch }}-${{ github.ref_name }}.dmg | ||
|
||
|
@@ -56,3 +64,8 @@ jobs: | |
path: | | ||
fabric-${{ matrix.os }}-${{ matrix.arch }}-${{ github.ref_name }} | ||
fabric-macos-${{ matrix.arch }}-${{ github.ref_name }}.dmg | ||
|
||
- name: Upload release artifact | ||
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') | ||
run: | | ||
gh release upload ${{ github.ref_name }} fabric-*-${{ matrix.arch }}-${{ github.ref_name }}* | ||
Comment on lines
+68
to
+71
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Upload the built files to GitHub Releases when invoked from a tag push. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should provide the workflow with permissions to upload assets to GitHub releases.