-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add GitHub Actions workflows for building and releasing binaries and …
…updating Docker image CI triggers
- Loading branch information
KingPin
committed
Feb 28, 2025
1 parent
4c0660a
commit aff6b54
Showing
2 changed files
with
105 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: Build and Release FanOut | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' # Trigger on any tag starting with 'v' | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: '1.21' # Use Go 1.21 or later | ||
|
||
- name: Get version from tag | ||
id: get_version | ||
run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV | ||
|
||
- name: Build for multiple platforms | ||
run: | | ||
mkdir -p dist | ||
# Build for Linux (amd64) | ||
GOOS=linux GOARCH=amd64 go build -trimpath -ldflags="-s -w -X main.Version=$VERSION" -o dist/fanout-linux-amd64 | ||
# Build for Linux (arm64) | ||
GOOS=linux GOARCH=arm64 go build -trimpath -ldflags="-s -w -X main.Version=$VERSION" -o dist/fanout-linux-arm64 | ||
# Build for Linux (armv7) | ||
GOOS=linux GOARCH=arm GOARM=7 go build -trimpath -ldflags="-s -w -X main.Version=$VERSION" -o dist/fanout-linux-armv7 | ||
# Build for macOS (amd64) | ||
GOOS=darwin GOARCH=amd64 go build -trimpath -ldflags="-s -w -X main.Version=$VERSION" -o dist/fanout-darwin-amd64 | ||
# Build for macOS (arm64 - Apple Silicon) | ||
GOOS=darwin GOARCH=arm64 go build -trimpath -ldflags="-s -w -X main.Version=$VERSION" -o dist/fanout-darwin-arm64 | ||
# Build for Windows | ||
GOOS=windows GOARCH=amd64 go build -trimpath -ldflags="-s -w -X main.Version=$VERSION" -o dist/fanout-windows-amd64.exe | ||
# Create checksums | ||
cd dist && sha256sum * > checksums.txt | ||
- name: Create Release | ||
id: create_release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
dist/fanout-linux-amd64 | ||
dist/fanout-linux-arm64 | ||
dist/fanout-linux-armv7 | ||
dist/fanout-darwin-amd64 | ||
dist/fanout-darwin-arm64 | ||
dist/fanout-windows-amd64.exe | ||
dist/checksums.txt | ||
draft: false | ||
prerelease: false | ||
generate_release_notes: true | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
docker: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Docker metadata | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: ghcr.io/${{ github.repository }} | ||
tags: | | ||
type=semver,pattern={{version}} | ||
type=semver,pattern={{major}}.{{minor}} | ||
type=raw,value=latest | ||
- name: Build and push container | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64,linux/arm64 | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters