Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate admintools tag #203

Merged
merged 9 commits into from
May 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 38 additions & 6 deletions .github/workflows/release-admin-tools.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
tdeebswihart marked this conversation as resolved.
Show resolved Hide resolved
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
Expand Down
Loading