v1.0.X-experimental #21
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: Intercept Image Release | |
on: | |
workflow_dispatch: | |
inputs: | |
logLevel: | |
description: 'Log level' | |
required: true | |
default: 'warning' | |
push: | |
tags: | |
- "*" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all history for all tags and branches | |
- name: Setup Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version-file: go.mod | |
- name: Get latest tag | |
run: | | |
# Try to get tag for the current commit | |
CURRENT_TAG=$(git describe --exact-match --tags HEAD 2>/dev/null || echo "") | |
# If no tag for current commit, get the most recent tag | |
if [ -z "$CURRENT_TAG" ]; then | |
CURRENT_TAG=$(git describe --tags --abbrev=0) | |
fi | |
# Remove 'v' prefix if present | |
VERSION=${CURRENT_TAG#v} | |
echo "VERSION=$VERSION" >> $GITHUB_ENV | |
- name: Get dependencies | |
run: | | |
go get -v -t -d ./... | |
if [ -f Gopkg.toml ]; then | |
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh | |
dep ensure | |
fi | |
- name: Build binaries | |
run: | | |
make build-linux/amd64 | |
make build-linux/arm64 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.actor }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push Docker images | |
run: | | |
PLATFORMS=(linux/amd64 linux/arm64) | |
for platform in "${PLATFORMS[@]}"; do | |
make docker-build-$platform | |
os=$(echo $platform | cut -d'/' -f1) | |
arch=$(echo $platform | cut -d'/' -f2) | |
docker tag test/intercept:$os-$arch xfhg/intercept:${{ env.VERSION }}-$os-$arch | |
docker tag test/intercept:$os-$arch xfhg/intercept:latest-$os-$arch | |
docker tag test/intercept:$os-$arch ghcr.io/${{ github.repository }}:${{ env.VERSION }}-$os-$arch | |
docker tag test/intercept:$os-$arch ghcr.io/${{ github.repository }}:latest-$os-$arch | |
docker push xfhg/intercept:${{ env.VERSION }}-$os-$arch | |
docker push xfhg/intercept:latest-$os-$arch | |
docker push ghcr.io/${{ github.repository }}:${{ env.VERSION }}-$os-$arch | |
docker push ghcr.io/${{ github.repository }}:latest-$os-$arch | |
done | |
- name: Create multi-arch manifests | |
run: | | |
# Create and push multi-arch manifest for DockerHub | |
docker manifest create xfhg/intercept:latest \ | |
xfhg/intercept:latest-linux-amd64 \ | |
xfhg/intercept:latest-linux-arm64 | |
docker manifest push xfhg/intercept:latest | |
# Create and push multi-arch manifest for GitHub Container Registry | |
docker manifest create ghcr.io/${{ github.repository }}:latest \ | |
ghcr.io/${{ github.repository }}:latest-linux-amd64 \ | |
ghcr.io/${{ github.repository }}:latest-linux-arm64 | |
docker manifest push ghcr.io/${{ github.repository }}:latest | |