Skip to content

Commit

Permalink
chore: update build action
Browse files Browse the repository at this point in the history
  • Loading branch information
boojack committed Nov 3, 2024
1 parent 0857e4e commit bd8462b
Showing 1 changed file with 48 additions and 9 deletions.
57 changes: 48 additions & 9 deletions .github/workflows/build-and-push-release-image.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
name: build-and-push-release-image
name: build-and-push-stable-image

on:
push:
branches:
# Run on pushing branches like `release/1.0.0`
- "release/*.*.*"
tags:
# Match stable and rc versions, such as 'v1.0.0' or 'v0.23.0-rc.0'
- "v*.*.*"
- "v*.*.*-rc.*"

jobs:
build-and-push-release-image:
build-and-push-stable-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Extract build args
# Extract version from branch name
# Example: branch name `release/1.0.0` sets up env.VERSION=1.0.0
# Extract version number and check if it's an rc version
run: |
echo "VERSION=${GITHUB_REF_NAME#release/}" >> $GITHUB_ENV
if [[ "${GITHUB_REF_NAME}" =~ -rc ]]; then
echo "PRE_RELEASE=true" >> $GITHUB_ENV
else
echo "PRE_RELEASE=false" >> $GITHUB_ENV
fi
echo "VERSION=${GITHUB_REF_NAME#v}" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
Expand All @@ -32,6 +40,36 @@ jobs:
uses: docker/setup-buildx-action@v3
with:
install: true
version: v0.9.1

# Metadata for stable versions
- name: Docker meta for stable
id: meta-stable
if: env.PRE_RELEASE == 'false'
uses: docker/metadata-action@v5
with:
images: |
yourselfhosted/slash
tags: |
type=semver,pattern={{version}},value=${{ env.VERSION }}
type=raw,value=stable
flavor: |
latest=true
labels: |
org.opencontainers.image.version=${{ env.VERSION }}
# Metadata for rc versions
- name: Docker meta for rc
id: meta-rc
if: env.PRE_RELEASE == 'true'
uses: docker/metadata-action@v5
with:
images: |
yourselfhosted/slash
tags: |
type=raw,value=${{ env.VERSION }}
labels: |
org.opencontainers.image.version=${{ env.VERSION }}
- name: Build and Push
id: docker_build
Expand All @@ -41,4 +79,5 @@ jobs:
file: ./Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: yourselfhosted/slash:latest, yourselfhosted/slash:${{ env.VERSION }}
tags: ${{ steps.meta-stable.outputs.tags || steps.meta-rc.outputs.tags }}
labels: ${{ steps.meta-stable.outputs.labels || steps.meta-rc.outputs.labels }}

0 comments on commit bd8462b

Please sign in to comment.