Merge pull request #12 from AlayaCare/repo_visibility #3
Workflow file for this run
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
name: Build Docker Image on Tag | |
on: | |
push: | |
tags: | |
- 'v[0-9]+.[0-9]+.[0-9]+' | |
permissions: | |
packages: write | |
contents: write | |
jobs: | |
build-binaries: | |
runs-on: ubuntu-latest | |
outputs: | |
linux-x86_64-binary-path: ${{ steps.upload-artifact-linux-x86_64.outputs.binary-path }} | |
linux-aarch64-binary-path: ${{ steps.upload-artifact-linux-aarch64.outputs.binary-path }} | |
darwin-arm64-binary-path: ${{ steps.upload-artifact-Darwin-arm64.outputs.binary-path }} | |
darwin-x86_64-binary-path: ${{ steps.upload-artifact-Darwin-x86_64.outputs.binary-path }} | |
windows-x86_64-binary-path: ${{ steps.upload-artifact-windows-x86_64.outputs.binary-path }} | |
steps: | |
# Checkout the code | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
# Set up Go environment | |
- name: Set up Go | |
uses: actions/setup-go@v5 | |
with: | |
go-version: '1.23' | |
# Build Go binaries for different platforms. Name is goliac-`uname -s`-`uname -m` (at least for linux and mac) | |
- name: Build binaries | |
run: | | |
mkdir -p dist | |
GOOS=linux GOARCH=amd64 go build -ldflags "-X github.com/goliac-project/goliac/internal/config.GoliacBuildVersion=${{ github.ref_name }}" -o dist/goliac-Linux-x86_64 ./cmd/goliac | |
GOOS=linux GOARCH=arm64 go build -ldflags "-X github.com/goliac-project/goliac/internal/config.GoliacBuildVersion=${{ github.ref_name }}" -o dist/goliac-Linux-aarch64 ./cmd/goliac | |
GOOS=darwin GOARCH=arm64 go build -ldflags "-X github.com/goliac-project/goliac/internal/config.GoliacBuildVersion=${{ github.ref_name }}" -o dist/goliac-Darwin-arm64 ./cmd/goliac | |
GOOS=darwin GOARCH=amd64 go build -ldflags "-X github.com/goliac-project/goliac/internal/config.GoliacBuildVersion=${{ github.ref_name }}" -o dist/goliac-Darwin-x86_64 ./cmd/goliac | |
GOOS=windows GOARCH=amd64 go build -ldflags "-X github.com/goliac-project/goliac/internal/config.GoliacBuildVersion=${{ github.ref_name }}" -o dist/goliac-win-x86_64 ./cmd/goliac | |
# Publish binaries as release assets | |
- name: Upload binaries to GitHub Release | |
uses: softprops/action-gh-release@v2 | |
with: | |
files: dist/* | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
build: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout 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 }} | |
- id: lower-repo | |
shell: pwsh | |
run: | | |
"::set-output name=repository::$($env:GITHUB_REPOSITORY.ToLowerInvariant())" | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
context: . | |
file: ./Dockerfile | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ghcr.io/${{ steps.lower-repo.outputs.repository }}:latest,ghcr.io/${{ steps.lower-repo.outputs.repository }}:${{ github.ref_name }} | |
build-args: | | |
GITHUB_REF=${{ github.ref_name }} | |