Update workflow file #12
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 and Release | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
build_and_release: | |
name: Build for Multiple Platforms and Create Release | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Code | |
uses: actions/checkout@v3 | |
- name: Setup Go | |
uses: actions/setup-go@v3 | |
with: | |
go-version: '1.21' | |
- name: Get the latest tag | |
id: get_latest_tag | |
run: echo "LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)" >> $GITHUB_ENV | |
- name: Build for Linux, Windows, macOS | |
run: | | |
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=${{ env.LATEST_TAG }}" -o release/gama-linux-amd64 main.go | |
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=${{ env.LATEST_TAG }}" -o release/gama-windows-amd64.exe main.go | |
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=${{ env.LATEST_TAG }}" -o release/gama-macos-amd64 main.go | |
GOOS=darwin GOARCH=arm64 CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=${{ env.LATEST_TAG }}" -o release/gama-macos-arm64 main.go | |
- name: Create Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: "release/gama-linux-amd64,release/gama-windows-amd64.exe,release/gama-macos-amd64,release/gama-macos-arm64" | |
token: ${{ secrets.GIT_TOKEN }} | |
draft: true | |
# Docker build and push steps | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and push Docker image | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
file: ./Dockerfile | |
push: true | |
tags: | | |
${{ secrets.DOCKER_USERNAME }}/gama:${{ env.LATEST_TAG }} | |
${{ secrets.DOCKER_USERNAME }}/gama:latest | |
build-args: | | |
TERM=xterm-256color |