Skip to content

Update Go version to 1.22.3 #135

Update Go version to 1.22.3

Update Go version to 1.22.3 #135

Workflow file for this run

name: Main
on: [push, pull_request]
env:
GO_VERSION: 1.22.3
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
# On tag, get tag version without v (e.g. v1.0.0 -> 1.0.0, v1.1.1-beta -> 1.1.1-beta)
- name: Get tag version
id: get_version
run: |
if [[ $GITHUB_REF == "refs/tags/v"* ]]; then
echo "Found release tag"
VERSION=${GITHUB_REF/refs\/tags\/v}
else
echo "No release tag found"
VERSION="local-build-only"
fi
echo "Using version: $VERSION"
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Build and Test Binary
env:
CGO_ENABLED: 0
run: |
go version
go mod download
SKIP_CONTEXT_ERROR_CHECK=true go test -test.timeout 50s
mkdir -p build/artifacts
for arch in amd64 arm64
do
echo "Building scuttle-linux-$arch binary"
GOOS=linux GOARCH="$arch" go build -o "build/linux/$arch/scuttle" -ldflags="-X 'main.Version=${{ steps.get_version.outputs.VERSION }}'"
zip -r -j "build/artifacts/scuttle-linux-$arch.zip" "build/linux/$arch/"
done
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_HUB_USER }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
if: startsWith(github.ref, 'refs/tags/')
# Build Docker image
# On tag, push Docker image
- name: Build Docker Image
uses: docker/build-push-action@v5
with:
platforms: linux/amd64,linux/arm64
push: ${{ startsWith(github.ref, 'refs/tags/') }}
build-args: |
VERSION=${{ steps.get_version.outputs.VERSION }}
GO_VERSION=${{ env.GO_VERSION }}
tags: |
kvij/scuttle:latest
kvij/scuttle:${{ steps.get_version.outputs.VERSION }}
# On tag, Create GitHub Release
- name: Release
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: build/artifacts/*.zip