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

Output major, minor and patch versions of the docker container #33

Merged
merged 1 commit into from
Oct 30, 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
42 changes: 34 additions & 8 deletions .github/workflows/periodic-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ on:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
VERSION: ""
TAG_MAJOR: ""
TAG_MINOR: ""
TAG_PATCH: ""
TAG_LATEST: ""

permissions: read-all

jobs:
Expand All @@ -27,29 +33,49 @@ jobs:
- name: Get the latest tag version
id: get_version
run: |
latest_tag=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "Latest tag: $latest_tag"
if [[ $latest_tag =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
latest_version=$(git describe --tags $(git rev-list --tags --max-count=1))
echo "Latest Version: $latest_version"
if [[ $latest_version =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
major=${BASH_REMATCH[1]}
echo "Major: $major"
minor=${BASH_REMATCH[2]}
echo "Minor: $minor"
patch=${BASH_REMATCH[3]}
echo "Patch: $patch"

new_patch=$((patch + 1))
new_tag="v${major}.${minor}.${new_patch}"
echo "New tag: $new_tag"
echo "TAG=$new_tag" >> $GITHUB_ENV

tag_major=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${major}
tag_minor=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${major}.${minor}
tag_patch=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${major}.${minor}.${new_patch}
tag_latest=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

echo "TAG_MAJOR: $tag_major"
echo "TAG_MAJOR=$tag_major" >> $GITHUB_ENV
echo "TAG_MINOR: $tag_minor"
echo "TAG_MINOR=$tag_minor" >> $GITHUB_ENV
echo "TAG_PATCH: $tag_patch"
echo "TAG_PATCH=$tag_patch" >> $GITHUB_ENV
echo "TAG_LATEST: $tag_latest"
echo "TAG_LATEST=$tag_latest" >> $GITHUB_ENV

new_version="v${major}.${minor}.${new_patch}"
echo "New Version: $new_version"
echo "VERSION=$new_version" >> $GITHUB_ENV
else
echo "Could not determine the latest tag version."
exit 1
fi

# Docs: https://github.com/marketplace/actions/create-release
- name: 'Create Release'
id: create_release
uses: ncipollo/release-action@v1
with:
body: "A Weekly release contianing upgrades to system packages in the base Rocker Linux container."
makeLatest: true
prerelease: false
tag: ${{ env.TAG }}
tag: ${{ env.VERSION }}

- name: Harden Runner
uses: step-security/harden-runner@91182cccc01eb5e619899d80e4e971d6181294a7 # v2.10.1
Expand All @@ -68,4 +94,4 @@ jobs:
with:
build-args: GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }},${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
tags: ${{ env.TAG_MAJOR }},${{ env.TAG_MINOR }},${{ env.TAG_PATCH }},${{ env.TAG_LATEST }}
Loading