Skip to content

CD Tag And Release #207

CD Tag And Release

CD Tag And Release #207

name: CD Tag And Release
on:
workflow_run:
workflows: [CD Build Distroless Unbound Docker Image]
types:
- completed
jobs:
tag_and_release:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
persist-credentials: false
- name: Import GPG key
id: IMPORT_GPG
uses: crazy-max/ghaction-import-gpg@v6
with:
gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }}
passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }}
git_user_signingkey: true
git_commit_gpgsign: true
git_tag_gpgsign: true
git_push_gpgsign: false
trust_level: 5
- name: Push tag and upload release to GitHub
env:
GITHUB_TOKEN: ${{ secrets.BOT_GITHUB_TOKEN }}
GIT_AUTHOR_NAME: ${{ steps.IMPORT_GPG.outputs.name }}
GIT_AUTHOR_EMAIL: ${{ steps.IMPORT_GPG.outputs.email }}
GIT_COMMITTER_NAME: ${{ steps.IMPORT_GPG.outputs.name }}
GIT_COMMITTER_EMAIL: ${{ steps.IMPORT_GPG.outputs.email }}
run: |
git remote set-url origin https://x-access-token:${{ secrets.BOT_GITHUB_TOKEN }}@github.com/${{ github.repository }}
IMAGE_BUILD_DATE="$(cat ./buildvars | grep "^IMAGE_BUILD_DATE=" | cut -d"=" -f2-)"
UNBOUND_VERSION="$(cat ./buildvars | grep "^UNBOUND_VERSION=" | cut -d"=" -f2-)"
UNBOUND_DOCKER_VERSION="$UNBOUND_VERSION-0"
RELEASE_TAG="v$UNBOUND_DOCKER_VERSION"
RELEASE_NOTE=$(echo -e "\x23\x23 $(date '+%Y-%m-%d') <madnuttah-bot>\n\x23\x23 What's Changed?\n\x2A Updated Unbound to version $UNBOUND_VERSION\n\n\x2A\x2ANLnet Labs Unbound changelog\x2A\x2A: https://github.com/NLnetLabs/unbound/releases/tag/release-$UNBOUND_VERSION")
git tag -a "$RELEASE_TAG" -m "$RELEASE_TAG"
git push -u origin "$RELEASE_TAG"
git fetch --all --tags
git checkout -b "$UNBOUND_DOCKER_VERSION" "$RELEASE_TAG"
git push --set-upstream origin "$UNBOUND_DOCKER_VERSION"
gh release create "$RELEASE_TAG" -t "$UNBOUND_DOCKER_VERSION" -n "$RELEASE_NOTE" --latest
exit 0