|
70 | 70 | done
|
71 | 71 | # shellcheck disable=SC2086
|
72 | 72 | cosign sign --recursive --yes ${images}
|
| 73 | + - name: Set VERSION |
| 74 | + if: github.ref == 'refs/heads/main' |
| 75 | + shell: bash |
| 76 | + run: | |
| 77 | + # shellcheck disable=SC2086 |
| 78 | + VERSION="$(\grep ${IMAGE}/Dockerfile -e '^FROM' | \head -n 1 | \sed -e 's/@.*$//; s/^.*://;')" |
| 79 | + if [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then |
| 80 | + \echo "VERSION=${VERSION}" >> "${GITHUB_ENV}" |
| 81 | + fi |
| 82 | + - name: Check if release already exists |
| 83 | + if: env.VERSION != '' |
| 84 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 85 | + id: check-release |
| 86 | + with: |
| 87 | + script: | |
| 88 | + const { VERSION } = process.env |
| 89 | + return github.rest.repos.getReleaseByTag({ |
| 90 | + owner: context.repo.owner, |
| 91 | + repo: context.repo.repo, |
| 92 | + tag: `v${VERSION}`, |
| 93 | + }).then(function(result) { |
| 94 | + core.debug(JSON.stringify(result)) |
| 95 | + core.info(`Release ${result.data.tag_name} found`) |
| 96 | + return result.data.tag_name |
| 97 | + }).catch(function(error) { |
| 98 | + if (error.status === 404) { |
| 99 | + core.info(`Release v${VERSION} not found`) |
| 100 | + return |
| 101 | + } else { |
| 102 | + throw error |
| 103 | + } |
| 104 | + }) |
| 105 | + result-encoding: string |
| 106 | + - name: Trigger Release |
| 107 | + if: env.VERSION != '' && steps.check-release.outputs.result == 'undefined' |
| 108 | + uses: actions/create-release@0cb9c9b65d5d1901c1f53e5e66eaf4afd303e70e # v1.1.4 |
| 109 | + env: |
| 110 | + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} |
| 111 | + with: |
| 112 | + tag_name: v${{ env.VERSION }} |
0 commit comments