Skip to content

Commit c999828

Browse files
committed
ci: also publish latest release branch containers
1 parent 5db384f commit c999828

File tree

1 file changed

+39
-5
lines changed

1 file changed

+39
-5
lines changed

.github/workflows/latest-release.yaml

Lines changed: 39 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,59 @@ on:
77
push:
88
branches:
99
- main
10+
- release/*
1011
workflow_dispatch:
1112

1213
concurrency: latest-release
1314

1415
env:
1516
IMAGE_NAME: trustd
16-
IMAGE_TAG: latest
1717
OPENSHIFT_NAMESPACE: trustify-latest
1818
OPENSHIFT_SERVER: https://api.cluster.trustification.rocks:6443
1919
APP_NAME: staging
2020

2121
jobs:
22+
init:
23+
runs-on: ubuntu-22.04
24+
outputs:
25+
version: ${{steps.version.outputs.version}}
26+
prerelease: ${{steps.state.outputs.prerelease}}
27+
steps:
28+
- name: Evaluate pre-release state
29+
id: state
30+
env:
31+
HEAD_REF: ${{github.head_ref}}
32+
run: |
33+
test -z "${HEAD_REF}" && (echo 'do-publish=true' >> $GITHUB_OUTPUT)
34+
if [[ "${{ github.event.ref }}" =~ ^refs/tags/v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
35+
echo release=true >> $GITHUB_OUTPUT
36+
echo release=true >> $GITHUB_ENV
37+
elif [[ "${{ github.event.ref }}" =~ ^refs/tags/v.*$ ]]; then
38+
echo prerelease=true >> $GITHUB_OUTPUT
39+
echo prerelease=true >> $GITHUB_ENV
40+
fi
41+
- name: Set version
42+
id: version
43+
run: |
44+
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
45+
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
46+
[[ "$VERSION" == "main" ]] && VERSION=latest
47+
[[ "${{ github.ref }}" == "refs/heads/release/"* ]] && VERSION=$(echo "$VERSION" | sed -e 's/^release\///')
48+
echo "version=$VERSION" >> $GITHUB_OUTPUT
49+
echo "version=$VERSION" >> $GITHUB_ENV
50+
- name: Show result
51+
run: |
52+
echo "Version: $version"
53+
echo "Release: $release"
54+
echo "Pre-release: $prerelease"
55+
2256
build:
2357
uses: ./.github/workflows/build-binary.yaml
2458
with:
2559
version: latest
2660

2761
publish:
28-
needs: [ build ]
62+
needs: [ init, build ]
2963
runs-on: ubuntu-22.04
3064

3165
outputs:
@@ -54,7 +88,7 @@ jobs:
5488
- uses: ./.github/actions/build-container
5589
with:
5690
image_name: ${{ env.IMAGE_NAME }}
57-
image_tag: ${{ env.IMAGE_TAG }}
91+
image_tag: ${{ needs.init.outputs.version }}
5892

5993
# Push to ghcr.io
6094

@@ -63,7 +97,7 @@ jobs:
6397
uses: redhat-actions/push-to-registry@v2
6498
with:
6599
image: ${{ env.IMAGE_NAME }}
66-
tags: ${{ env.IMAGE_TAG }}
100+
tags: ${{ needs.init.outputs.version }}
67101
registry: ghcr.io/${{ github.repository_owner }}
68102
username: ${{ github.repository_owner }}
69103
password: ${{ secrets.GITHUB_TOKEN }}
@@ -77,7 +111,7 @@ jobs:
77111
run_ui_tests: true
78112

79113
deploy:
80-
if: ${{ github.repository == 'trustification/trustify' }}
114+
if: ${{ (github.repository == 'trustification/trustify') && (needs.init.outputs.version == 'main') }}
81115
runs-on: ubuntu-22.04
82116
needs:
83117
- publish

0 commit comments

Comments
 (0)