-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (94 loc) · 3.58 KB
/
release.yml
File metadata and controls
107 lines (94 loc) · 3.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
name: Release
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+*'
workflow_dispatch:
inputs:
tag:
description: 'Docker tag override (for manual runs, e.g. 0.0.1-test)'
required: false
default: ''
permissions:
contents: read
packages: write
env:
DOCKERHUB_IMAGE: durableworkflow/server
GHCR_IMAGE: ghcr.io/durable-workflow/server
jobs:
publish:
name: Build and push Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Set up QEMU
uses: docker/setup-qemu-action@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- name: Log in to Docker Hub
uses: docker/login-action@v4
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Log in to GHCR
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract image metadata
id: meta
uses: docker/metadata-action@v6
with:
images: |
${{ env.DOCKERHUB_IMAGE }}
${{ env.GHCR_IMAGE }}
# On a release tag like 0.1.0, produces tags:
# durableworkflow/server:0.1.0
# durableworkflow/server:0.1
# durableworkflow/server:0
# durableworkflow/server:latest
# ghcr.io/durable-workflow/server:0.1.0
# ghcr.io/durable-workflow/server:0.1
# ghcr.io/durable-workflow/server:0
# ghcr.io/durable-workflow/server:latest
# workflow_dispatch with an input uses that as a single tag.
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=raw,value=latest,enable=${{ startsWith(github.ref, 'refs/tags/') }}
type=raw,value=${{ github.event.inputs.tag }},enable=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.tag != '' }}
labels: |
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.revision=${{ github.sha }}
# Automatically detect the latest workflow package pre-release tag
# This allows you to tag workflow releases (2.0.0-alpha.2, etc) and have
# server builds automatically pick them up without manual workflow edits.
- name: Get latest workflow package version
id: workflow
run: |
# Fetch latest pre-release tag from workflow repo (2.0.0-alpha.x, 2.0.0-beta.x)
LATEST_TAG=$(git ls-remote --tags --refs --sort=v:refname https://github.com/durable-workflow/workflow.git \
| grep -E 'refs/tags/2\.0\.0-(alpha|beta)\.' \
| tail -1 \
| sed 's/.*refs\/tags\///')
# Fallback to v2 branch if no pre-release tags exist
if [ -z "$LATEST_TAG" ]; then
LATEST_TAG="v2"
fi
echo "tag=$LATEST_TAG" >> $GITHUB_OUTPUT
echo "Using workflow package version: $LATEST_TAG"
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
build-args: |
WORKFLOW_PACKAGE_REF=${{ steps.workflow.outputs.tag }}