Skip to content

Commit 8de90e0

Browse files
committed
Try 100 version of automated release
1 parent 9804e4c commit 8de90e0

1 file changed

Lines changed: 31 additions & 30 deletions

File tree

.github/workflows/delivery.yml

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,41 @@
11
name: Delivery
22

33
on:
4-
# push:
5-
# branches: [main]
6-
release:
7-
types: [published]
4+
push:
5+
branches: [main]
86
pull_request:
97
branches: [main]
10-
workflow_dispatch:
118

129
permissions:
1310
contents: read
1411
packages: write
1512
security-events: write
1613

1714
jobs:
15+
config:
16+
runs-on: ubuntu-latest
17+
outputs:
18+
profile: ${{ steps.resolve.outputs.profile }}
19+
version: ${{ steps.resolve.outputs.version }}
20+
is_release: ${{ steps.resolve.outputs.is_release }}
21+
steps:
22+
- name: Resolve build config
23+
id: resolve
24+
run: |
25+
MSG="${{ github.event.head_commit.message }}"
26+
if [[ "$MSG" =~ ^chore:\ release\ (v[0-9]+\.[0-9]+\.[0-9]+) ]]; then
27+
echo "is_release=true" >> "$GITHUB_OUTPUT"
28+
echo "version=${BASH_REMATCH[1]}" >> "$GITHUB_OUTPUT"
29+
echo "profile=release" >> "$GITHUB_OUTPUT"
30+
else
31+
echo "is_release=false" >> "$GITHUB_OUTPUT"
32+
echo "version=" >> "$GITHUB_OUTPUT"
33+
echo "profile=edge" >> "$GITHUB_OUTPUT"
34+
fi
35+
1836
build-amd64:
1937
runs-on: ubuntu-latest
38+
needs: [config]
2039
outputs:
2140
digest: ${{ steps.build.outputs.digest }}
2241
steps:
@@ -25,15 +44,6 @@ jobs:
2544
with:
2645
fetch-depth: 0
2746

28-
- name: Select build profile
29-
id: config
30-
run: |
31-
if [[ "${{ github.event_name }}" == "release" ]]; then
32-
echo "profile=release" >> "$GITHUB_OUTPUT"
33-
else
34-
echo "profile=edge" >> "$GITHUB_OUTPUT"
35-
fi
36-
3747
- name: Set up Docker Buildx
3848
uses: docker/setup-buildx-action@v4
3949

@@ -53,7 +63,7 @@ jobs:
5363
push: true
5464
provenance: false
5565
tags: ghcr.io/${{ github.repository }}:build-${{ github.run_id }}-amd64
56-
build-args: CARGO_PROFILE=${{ steps.config.outputs.profile }}
66+
build-args: CARGO_PROFILE=${{ needs.config.outputs.profile }}
5767
cache-from: type=gha,scope=build-amd64
5868
cache-to: type=gha,mode=max,scope=build-amd64
5969

@@ -75,6 +85,7 @@ jobs:
7585

7686
build-arm64:
7787
runs-on: ubuntu-24.04-arm
88+
needs: [config]
7889
outputs:
7990
digest: ${{ steps.build.outputs.digest }}
8091
steps:
@@ -83,15 +94,6 @@ jobs:
8394
with:
8495
fetch-depth: 0
8596

86-
- name: Select build profile
87-
id: config
88-
run: |
89-
if [[ "${{ github.event_name }}" == "release" ]]; then
90-
echo "profile=release" >> "$GITHUB_OUTPUT"
91-
else
92-
echo "profile=edge" >> "$GITHUB_OUTPUT"
93-
fi
94-
9597
- name: Set up Docker Buildx
9698
uses: docker/setup-buildx-action@v4
9799

@@ -111,25 +113,24 @@ jobs:
111113
push: true
112114
provenance: false
113115
tags: ghcr.io/${{ github.repository }}:build-${{ github.run_id }}-arm64
114-
build-args: CARGO_PROFILE=${{ steps.config.outputs.profile }}
116+
build-args: CARGO_PROFILE=${{ needs.config.outputs.profile }}
115117
cache-from: type=gha,scope=build-arm64
116118
cache-to: type=gha,mode=max,scope=build-arm64
117119

118120
merge:
119121
runs-on: ubuntu-latest
120-
needs: [build-amd64, build-arm64]
122+
needs: [config, build-amd64, build-arm64]
121123
steps:
122124
- name: Docker meta
123125
id: meta
124126
uses: docker/metadata-action@v6
125127
with:
126128
images: ghcr.io/${{ github.repository }}
127129
tags: |
128-
type=semver,pattern={{version}},value=${{ github.event.release.tag_name }},enable=${{ github.event_name == 'release' }}
129-
type=semver,pattern={{major}}.{{minor}},value=${{ github.event.release.tag_name }},enable=${{ github.event_name == 'release' }}
130-
type=edge,enable=${{ github.event_name != 'release' }}
130+
type=semver,pattern={{version}},value=${{ needs.config.outputs.version }},enable=${{ needs.config.outputs.is_release == 'true' }}
131+
type=semver,pattern={{major}}.{{minor}},value=${{ needs.config.outputs.version }},enable=${{ needs.config.outputs.is_release == 'true' }}
132+
type=edge,branch=main,enable=${{ github.event_name == 'push' && needs.config.outputs.is_release != 'true' }}
131133
type=ref,event=pr
132-
type=ref,event=branch,enable=${{ github.event_name == 'workflow_dispatch' }}
133134
134135
- name: Set up Docker Buildx
135136
uses: docker/setup-buildx-action@v4

0 commit comments

Comments
 (0)