Release Armada Operator - RC #20
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release Armada Operator - RC | |
on: | |
workflow_run: | |
types: [completed] | |
workflows: [CI] | |
branches: | |
- main | |
permissions: | |
contents: write | |
jobs: | |
validate: | |
if: github.event.workflow_run.event == 'push' && github.event.workflow_run.conclusion == 'success' && github.repository_owner == 'armadaproject' | |
name: "Validate revision" | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v3" | |
with: | |
fetch-depth: 0 | |
# The given ref should belong to the main branch. | |
# If it's main, it shouldn't be more than 2 commits away (in case another push happened in the meantime). | |
# Anything else is invalid. | |
- name: Validate ref | |
run: | | |
ref='${{ github.event.workflow_run.head_branch }}' | |
sha='${{ github.event.workflow_run.head_sha }}' | |
[ "$ref" == "main" ] && | |
[ $(git branch --contains=$sha main | wc -l) -eq 1 ] && | |
[ $(git rev-list --count $sha..main) -le 2 ] | |
if [ $? -ne 0 ]; then | |
echo "::error ::Invalid ref $ref $sha: must be a merge to main branch and not more than 2 commits away" | |
exit 1 | |
fi | |
release: | |
name: Release | |
runs-on: "ubuntu-22.04" | |
environment: armada-dockerhub | |
steps: | |
- name: "Checkout" | |
uses: "actions/checkout@v3" | |
with: | |
fetch-depth: 0 | |
- name: Setup Golang with cache | |
uses: magnetikonline/action-golang-cache@v4 | |
with: | |
go-version: ~1.20 | |
- name: Set up Docker Buildx | |
id: buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: "Docker login" | |
uses: "docker/login-action@v2" | |
with: | |
username: "${{ secrets.DOCKERHUB_USER }}" | |
password: "${{ secrets.DOCKERHUB_PASS }}" | |
- name: Install GitVersion | |
uses: gittools/actions/gitversion/setup@v0 | |
with: | |
versionSpec: "6.x" | |
includePrerelease: true | |
- name: Determine Version | |
id: gitversion | |
uses: gittools/actions/gitversion/execute@v0 | |
- name: Display GitVersion outputs (step output) | |
run: | | |
echo "Major: ${{ steps.gitversion.outputs.major }}" | |
echo "Minor: ${{ steps.gitversion.outputs.minor }}" | |
echo "Patch: ${{ steps.gitversion.outputs.patch }}" | |
echo "Sha: ${{ steps.gitversion.outputs.sha }}" | |
echo "ShortSha: ${{ steps.gitversion.outputs.shortSha }}" | |
- name: Set next RC version | |
id: "set_next_version" | |
run: echo "next_version=${{ steps.gitversion.outputs.majorMinorPatch }}-rc-${{ steps.gitversion.outputs.shortSha }}" >> $GITHUB_OUTPUT | |
- uses: rickstaa/action-create-tag@v1 | |
id: "tag_create" | |
with: | |
tag: "v${{ steps.set_next_version.outputs.next_version }}" | |
tag_exists_error: true | |
message: "Armada Release Candidate for version v${{ steps.gitversion.outputs.majorMinorPatch }}" | |
- name: "Run GoReleaser" | |
uses: "goreleaser/goreleaser-action@v4" | |
with: | |
distribution: "goreleaser" | |
version: "v1.18.2" | |
args: "-f ./.goreleaser.yaml release --clean --skip-sbom --skip-sign" | |
env: | |
DOCKER_REPO: "gresearch" | |
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" | |
DOCKER_BUILDX_BUILDER: "${{ steps.buildx.outputs.name }}" | |
DOCKER_BUILDX_CACHE_FROM: "type=gha" | |
DOCKER_BUILDX_CACHE_TO: "type=gha,mode=max" |