|
7 | 7 | push:
|
8 | 8 | branches:
|
9 | 9 | - main
|
| 10 | + - release/* |
10 | 11 | workflow_dispatch:
|
11 | 12 |
|
12 | 13 | concurrency: latest-release
|
13 | 14 |
|
14 | 15 | env:
|
15 | 16 | IMAGE_NAME: trustd
|
16 |
| - IMAGE_TAG: latest |
17 | 17 | OPENSHIFT_NAMESPACE: trustify-latest
|
18 | 18 | OPENSHIFT_SERVER: https://api.cluster.trustification.rocks:6443
|
19 | 19 | APP_NAME: staging
|
20 | 20 |
|
21 | 21 | 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 | +
|
22 | 56 | build:
|
23 | 57 | uses: ./.github/workflows/build-binary.yaml
|
24 | 58 | with:
|
25 | 59 | version: latest
|
26 | 60 |
|
27 | 61 | publish:
|
28 |
| - needs: [ build ] |
| 62 | + needs: [ init, build ] |
29 | 63 | runs-on: ubuntu-22.04
|
30 | 64 |
|
31 | 65 | outputs:
|
|
54 | 88 | - uses: ./.github/actions/build-container
|
55 | 89 | with:
|
56 | 90 | image_name: ${{ env.IMAGE_NAME }}
|
57 |
| - image_tag: ${{ env.IMAGE_TAG }} |
| 91 | + image_tag: ${{ needs.init.outputs.version }} |
58 | 92 |
|
59 | 93 | # Push to ghcr.io
|
60 | 94 |
|
|
63 | 97 | uses: redhat-actions/push-to-registry@v2
|
64 | 98 | with:
|
65 | 99 | image: ${{ env.IMAGE_NAME }}
|
66 |
| - tags: ${{ env.IMAGE_TAG }} |
| 100 | + tags: ${{ needs.init.outputs.version }} |
67 | 101 | registry: ghcr.io/${{ github.repository_owner }}
|
68 | 102 | username: ${{ github.repository_owner }}
|
69 | 103 | password: ${{ secrets.GITHUB_TOKEN }}
|
|
77 | 111 | run_ui_tests: true
|
78 | 112 |
|
79 | 113 | deploy:
|
80 |
| - if: ${{ github.repository == 'trustification/trustify' }} |
| 114 | + if: ${{ (github.repository == 'trustification/trustify') && (needs.init.outputs.version == 'main') }} |
81 | 115 | runs-on: ubuntu-22.04
|
82 | 116 | needs:
|
83 | 117 | - publish
|
|
0 commit comments