mirror of
https://github.com/aykhans/slash-e.git
synced 2025-04-08 09:33:59 +00:00
chore: update build action
This commit is contained in:
parent
0857e4ea68
commit
bd8462b2b3
@ -1,14 +1,18 @@
|
||||
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
|
||||
|
||||
@ -16,10 +20,14 @@ jobs:
|
||||
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
|
||||
@ -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
|
||||
@ -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 }}
|
||||
|
Loading…
x
Reference in New Issue
Block a user