Skip to content

chore: build for multiple architectures on release (#54) #22

chore: build for multiple architectures on release (#54)

chore: build for multiple architectures on release (#54) #22

Workflow file for this run

name: release
on:
push:
tags:
- "v*"
permissions:
# Required to publish a release
contents: write
# Necessary to push docker images to ghcr.io.
packages: write
# Necessary for GCP authentication (https://github.com/google-github-actions/setup-gcloud#usage)
id-token: write
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Build and publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Echo Go Cache Paths
id: go-cache-paths
run: |
echo "GOCACHE=$(go env GOCACHE)" >> ${{ runner.os == 'Windows' && '$env:' || '$' }}GITHUB_OUTPUT
echo "GOMODCACHE=$(go env GOMODCACHE)" >> ${{ runner.os == 'Windows' && '$env:' || '$' }}GITHUB_OUTPUT
- name: Go Build Cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.GOCACHE }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.**', '**.go') }}
- uses: actions/setup-go@v3
with:
go-version: "~1.20"
- name: Build
run: ./scripts/build.sh --arch=amd64 --arch=arm64 --arch=arm
- name: Docker Login
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Push
run: |
VERSION=$(./scripts/version.sh)
BASE=ghcr.io/coder/envbuilder
IMAGE=$BASE:$VERSION
for arch in ( amd64 arm64 arm ); do
docker tag envbuilder:$arch $IMAGE-$arch
docker push $IMAGE-$arch
done
docker push $BASE:latest