Skip to content

Release

Release #3

Workflow file for this run

name: Release
on:
release:
types:
- published
jobs:
# step 1) take the sha we are on, and push a tag matching the release name
promote_tag:
name: 'Promote Tag'
timeout-minutes: 7
runs-on: 'ubuntu-latest'
permissions:
contents: read
packages: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"
# get the associated sha
- name: Get Existing Tag
run: echo "tag=sha-$(git rev-parse --short=7 HEAD)" >> $GITHUB_OUTPUT
id: current-tag
# login to the registry
- name: Log into registry
timeout-minutes: 5
uses: docker/login-action@1f401f745bf57e30b3a2800ad308a87d2ebdf14b
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# get the version from gradle, this is used in the chart
# we need to ensure this tag exists before publishing the chart
- name: Output Gradle Version
id: version
run: |
echo "New version will be $(./gradlew --console=plain -q printVersion)"
echo "version=$(./gradlew --console=plain -q printVersion | head -n 3 | tail -1)" >> $GITHUB_OUTPUT
# retag, this is same repo but could be tweaked to push to a prod repo
- name: Promote Tag
run: |
skopeo copy --all docker://ghcr.io/${{ github.repository }}:${{ steps.current-tag.outputs.tag }} \
docker://ghcr.io/${{ github.repository }}:${{ steps.version.outputs.version }}
# step 2) build and publish the helm chart to an oci repo.
publish_chart:
name: 'Publish Chart'
runs-on: 'ubuntu-latest'
timeout-minutes: 7
needs:
- promote_tag
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-java@v3
with:
distribution: "zulu"
java-version: "17"
# login to the registry for oci pushes
- name: Log into registry
timeout-minutes: 5
uses: docker/login-action@1f401f745bf57e30b3a2800ad308a87d2ebdf14b
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# use gradle tasks to build the chart
- name: Execute Gradle Tasks
uses: gradle/gradle-build-action@v2.9.0
with:
gradle-version: 8.3
arguments: k8sResource k8sHelm
- name: Pack Helm Sub Charts
run: |
cd build/jkube/helm/$(./gradlew --console=plain -q printProjectName)/kubernetes/ && \
helm dependency update && \
helm dependency build
- name: Execute Gradle Tasks
uses: gradle/gradle-build-action@v2.9.0
env:
HELM_REPO_PATH: "${{ github.repository_owner }}/helm"
HELM_REPO_USERNAME: "${{ github.actor }}"
HELM_REPO_PASSWORD: "${{ secrets.GITHUB_TOKEN }}"
with:
gradle-version: 8.3
arguments: k8sHelmPush
# # we've already logged into the registry use helm to push, in the future use k8sHelmPush task
# - name: Helm Publish
# run: |
# cd build/jkube/helm/$(./gradlew --console=plain -q printProjectName)/kubernetes/ && \
# helm package . && \
# helm push *.tgz oci://ghcr.io/${{ github.repository_owner }}/helm