Skip to content

Merge pull request #66 from crazy-max/update #191

Merge pull request #66 from crazy-max/update

Merge pull request #66 from crazy-max/update #191

Workflow file for this run

name: build
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
push:
branches:
- 'main'
tags:
- 'v*'
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
env:
DOCKERHUB_SLUG: crazymax/goxx
GHCR_SLUG: ghcr.io/crazy-max/goxx
PLATFORMS: linux/amd64,linux/arm64
jobs:
prepare:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Cache
uses: actions/cache@v3
with:
path: /tmp/.goxx-cache
key: ${{ runner.os }}-goxx-base-${{ github.sha }}
restore-keys: |
${{ runner.os }}-goxx-base-
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Build base (cache only)
uses: docker/bake-action@v3
with:
targets: base
set: |
*.platform=${{ env.PLATFORMS }}
*.cache-from=type=gha,scope=base
*.cache-to=type=gha,scope=base,mode=max
build:
needs: prepare
runs-on: ubuntu-latest
env:
LATEST_CURRENT: 1.21.5
LATEST_PREVIOUS: 1.20.12
strategy:
fail-fast: false
matrix:
go_version:
- 1.20.0
- 1.20.1
- 1.20.2
- 1.20.3
- 1.20.4
- 1.20.5
- 1.20.6
- 1.20.7
- 1.20.8
- 1.20.9
- 1.20.10
- 1.20.11
- 1.20.12
- 1.21.0
- 1.21.1
- 1.21.2
- 1.21.3
- 1.21.4
- 1.21.5
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Remove dotnet
run: sudo rm -rf /usr/share/dotnet
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Tags
id: tags
uses: actions/github-script@v6
with:
result-encoding: string
script: |
const os = require('os');
const majorMinor = "${{ matrix.go_version }}".match(/[0-9]+\.[0-9]+/g)[0];
const tags = ["${{ matrix.go_version }}"];
switch ("${{ matrix.go_version }}") {
case "${{ env.LATEST_CURRENT }}": {
tags.push(majorMinor, "latest");
break;
}
case "${{ env.LATEST_PREVIOUS }}": {
tags.push(majorMinor);
break;
}
}
return tags.join(os.EOL);
-
name: Docker meta
id: meta
uses: docker/metadata-action@v4
with:
images: |
${{ env.DOCKERHUB_SLUG }}
${{ env.GHCR_SLUG }}
tags: ${{ steps.tags.outputs.result }}
labels: |
org.opencontainers.image.title=goxx (go-${{ matrix.go_version }})
org.opencontainers.image.vendor=CrazyMax
-
name: Login to DockerHub
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
-
name: Login to GHCR
if: startsWith(github.ref, 'refs/tags/v')
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build goxx
uses: docker/bake-action@v3
with:
files: |
./docker-bake.hcl
${{ steps.meta.outputs.bake-file }}
targets: image
set: |
*.platform=${{ env.PLATFORMS }}
*.args.GO_VERSION=${{ matrix.go_version }}
*.cache-from=type=gha,scope=base
push: ${{ startsWith(github.ref, 'refs/tags/v') }}