Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions .github/project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
current-version: "0.7.0"
next-version: "0.8.0"
74 changes: 74 additions & 0 deletions .github/workflows/prepare-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Prepare Release PR

on:
push:
branches: [main]
paths:
- '.github/project.yml'

jobs:
prepare-release:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write

steps:
- name: Checkout
uses: actions/checkout@v5

- name: Read version from project.yml
id: read-version
run: |
CURRENT_VERSION=$(yq '.current-version' .github/project.yml)
NEXT_VERSION=$(yq '.next-version' .github/project.yml)
echo "current-version=${CURRENT_VERSION}" >> "${GITHUB_OUTPUT}"
echo "next-version=${NEXT_VERSION}" >> "${GITHUB_OUTPUT}"
echo "Release version: ${CURRENT_VERSION}"
echo "Next version: ${NEXT_VERSION}"

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"

- name: Create release branch and update versions
run: |
RELEASE_VERSION=${{ steps.read-version.outputs.current-version }}
git checkout -b release/${RELEASE_VERSION}

export TAG_VERSION=${RELEASE_VERSION}
yq '.appVersion = env(TAG_VERSION)' -i ./deploy/charts/godaddy-webhook/Chart.yaml
yq '.version = env(TAG_VERSION)' -i ./deploy/charts/godaddy-webhook/Chart.yaml
yq '.image.tag = env(TAG_VERSION)' -i ./deploy/charts/godaddy-webhook/values.yaml

git commit -asm "chore: bump Helm chart version to ${RELEASE_VERSION}"
git push origin release/${RELEASE_VERSION}

- name: Create Pull Request
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
RELEASE_VERSION=${{ steps.read-version.outputs.current-version }}
NEXT_VERSION=${{ steps.read-version.outputs.next-version }}

gh pr create \
--base main \
--head release/${RELEASE_VERSION} \
--title "Release ${RELEASE_VERSION}" \
--body "$(cat <<EOF
## Release ${RELEASE_VERSION}

This PR was automatically created by updating \`.github/project.yml\`.

### Changes
- Helm chart \`appVersion\` set to \`${RELEASE_VERSION}\`
- Helm chart \`version\` set to \`${RELEASE_VERSION}\`
- Docker image tag set to \`${RELEASE_VERSION}\`

### Next version
After merging, the next development version will be \`${NEXT_VERSION}\`.

> **Merging this PR will trigger the release workflow.**
EOF
)"
102 changes: 38 additions & 64 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
name: Release Godaddy Webhook Helm Chart

on:
workflow_dispatch:
inputs:
version:
description: 'The version you want to release (e.g 0.3.0).'
required: true
pull_request:
types: [closed]
branches: [main]

jobs:
release:
runs-on: ubuntu-latest
# if: contains(github.event.head_commit.message, '[to_release]')
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
permissions:
contents: write # for creating Releases .tgz (403 from chart-releaser-action if not set)
#pages: write # not required for chart-releaser-action
contents: write

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Extract release version
id: version
run: |
RELEASE_VERSION=$(yq '.current-version' .github/project.yml)
NEXT_VERSION=$(yq '.next-version' .github/project.yml)
echo "release=${RELEASE_VERSION}" >> "${GITHUB_OUTPUT}"
echo "next=${NEXT_VERSION}" >> "${GITHUB_OUTPUT}"
echo "Release version: ${RELEASE_VERSION}"
echo "Next version: ${NEXT_VERSION}"

- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
Expand All @@ -28,81 +36,47 @@ jobs:
- name: Install Helm
uses: azure/setup-helm@v3

- name: Create release branch
run: git checkout -b release/${{ github.event.inputs.version }}

- name: Tag chart and image version
id: tag-chart
run: |
export TAG_VERSION=${{ github.event.inputs.version }}
echo "Tag version: ${TAG_VERSION}"

yq '.appVersion = env(TAG_VERSION)' -i ./deploy/charts/godaddy-webhook/Chart.yaml
yq '.version = env(TAG_VERSION)' -i ./deploy/charts/godaddy-webhook/Chart.yaml
yq '.image.tag = env(TAG_VERSION)' -i ./deploy/charts/godaddy-webhook/values.yaml

echo "Git status ..."
git status
git branch
git commit -asm "Update Helm chart version to $TAG_VERSION"

echo "Git status ..."
git status
git push origin release/${TAG_VERSION}

echo "TAG_VERSION=${TAG_VERSION}" >> "${GITHUB_OUTPUT}"

# - name: Login to Quay.io Hub
# uses: docker/login-action@v1
# with:
# registry: quay.io
# username: ${{ secrets.QUAY_ROBOT_USER }}
# password: ${{ secrets.QUAY_ROBOT_TOKEN }}
#
# - name: Build the container image
# run: |
# NEW_VERSION="${{ steps.tag-chart.outputs.TAG_VERSION }}"
# docker build -t cert-manager-webhook-godaddy:${NEW_VERSION} -f Dockerfile .
#
# TAG_ID=$(docker images -q cert-manager-webhook-godaddy:${NEW_VERSION})
# docker tag ${TAG_ID} quay.io/snowdrop/cert-manager-webhook-godaddy:${NEW_VERSION}
# docker push quay.io/snowdrop/cert-manager-webhook-godaddy:${NEW_VERSION}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build & push Docker image
uses: mr-smithers-excellent/docker-build-push@v6
with:
image: snowdrop/cert-manager-webhook-godaddy
tags: ${{ steps.tag-chart.outputs.TAG_VERSION }}, latest
tags: ${{ steps.version.outputs.release }}, latest
enableBuildKit: true
multiPlatform: true
platform: linux/amd64,linux/arm64
registry: quay.io
username: ${{ secrets.QUAY_ROBOT_USER }}
password: ${{ secrets.QUAY_ROBOT_TOKEN }}


- name: Run chart-releaser
uses: helm/chart-releaser-action@v1.5.0
with:
charts_dir: deploy/charts
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

- name: Push back the release branch and delete it
- name: Tag the release
run: |
RELEASE_VERSION="${{ steps.version.outputs.release }}"
git tag v${RELEASE_VERSION}
git push origin v${RELEASE_VERSION}

- name: Set next development version
run: |
TAG_VERSION="${{ steps.tag-chart.outputs.TAG_VERSION }}"

git checkout main
git pull
git merge release/${TAG_VERSION}
NEXT_VERSION="${{ steps.version.outputs.next }}"

export TAG_VERSION=${NEXT_VERSION}
yq '.appVersion = env(TAG_VERSION)' -i ./deploy/charts/godaddy-webhook/Chart.yaml
yq '.version = env(TAG_VERSION)' -i ./deploy/charts/godaddy-webhook/Chart.yaml
yq '.image.tag = env(TAG_VERSION)' -i ./deploy/charts/godaddy-webhook/values.yaml

git commit -asm "chore: set next development version to ${NEXT_VERSION}"
git push origin main

echo "Tagging main"
git tag v${TAG_VERSION}
git push origin v${TAG_VERSION}

# TODO: Should we delete it ??
git push origin --delete release/${{ steps.tag-chart.outputs.TAG_VERSION }}

- name: Cleanup release branch
run: |
RELEASE_VERSION="${{ steps.version.outputs.release }}"
git push origin --delete release/${RELEASE_VERSION} || true
Loading