diff --git a/.github/workflows/release-admin-tools.yml b/.github/workflows/release-admin-tools.yml index 69f3287b..e34c4edd 100644 --- a/.github/workflows/release-admin-tools.yml +++ b/.github/workflows/release-admin-tools.yml @@ -8,9 +8,9 @@ on: commit: description: "Repo Commit sha" required: true - admintools_tag: - description: "The tag for the new admintools image" - required: true + patch: + description: "The optional patch version of the admintools image" + required: false latest: type: boolean description: "Also update latest tag" @@ -23,19 +23,51 @@ on: default: false jobs: - retag-and-release: + release-admin-tools: name: "Re-tag and release images" runs-on: ubuntu-latest steps: + # Main - uses: actions/checkout@v4 + # For the action itself + - name: Check out target commit + uses: actions/checkout@v4 + with: + path: target + submodules: "true" + ref: ${{ github.event.inputs.commit }} - uses: actions/setup-go@v5 with: - go-version-file: "**/go.mod" + go-version-file: "src/go.mod" + - name: Calculate admintools tag + run: | + get_tag() { + # We need to remove the `shallow` marker for this submodule or else + # `git describe --tags` won't find our tags + cd "target/$1" + # We need to fetch the tags before git describe will do what we want + # We _only_ fetch the tags to save time + git fetch origin 'refs/tags/*:refs/tags/*' >&2 + rm -f ../.git/modules/$1/shallow + git describe --tags --always | cut -d '-' -f-2 + } + + tag=$(date "+%Y.%-m.%-d") + if [ -n "${{inputs.patch}}" ]; then + tag="${tag}-p${{inputs.patch}}" + fi + + tag="${tag}+" + while read module; do + tag="${tag}${module}-$(get_tag ${module})." + done < <(git submodule status | cut -d ' ' -f3 | grep -v dockerize) + + echo "TAG=${tag%.}" >> "${GITHUB_ENV}" - name: Copy images env: COMMIT: ${{ github.event.inputs.commit }} - TAG: ${{ github.event.inputs.admintools_tag }} + TAG: ${{ env.TAG }} USERNAME: ${{ secrets.DOCKER_USERNAME }} PASSWORD: ${{ secrets.DOCKER_PAT }} IMAGES: admintools