Skip to content

Commit

Permalink
fix: release ci helm (#285)
Browse files Browse the repository at this point in the history
* fix helm release CI

* remove redundant script

* rename broken reference in release ci
  • Loading branch information
dejanzele authored Jul 21, 2023
1 parent c600644 commit 1a54b9a
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 74 deletions.
36 changes: 8 additions & 28 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
sha='${{ github.event.workflow_run.head_sha }}'
[[ $ref =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]] &&
[ $(git rev-parse refs/tags/$ref) == $sha ] &&
[ $(git tag --points-at $sha | grep -E "^$ref\$" | wc -l) -eq 1 ] &&
[ $(git branch --contains=$sha main | wc -l) -eq 1 ]
if [ $? -ne 0 ]; then
echo "::error ::Invalid ref $ref $sha: must be a tag, belong to the main branch and match the semver regex"
Expand Down Expand Up @@ -81,7 +81,7 @@ jobs:
uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: v1.18.2
version: v1.19.2
args: "-f ./.goreleaser.yaml release --clean"
env:
FULL_RELEASE: true
Expand All @@ -90,30 +90,10 @@ jobs:
DOCKER_BUILDX_BUILDER: "${{ steps.buildx.outputs.name }}"
DOCKER_BUILDX_CACHE_FROM: "type=gha"
DOCKER_BUILDX_CACHE_TO: "type=gha,mode=max"
release-chart:
name: Release Chart
invoke-chart-push:
name: Invoke Chart push
needs: release
runs-on: ubuntu-22.04

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

- name: Sync version
run: scripts/update_chart.sh

- name: Commit & push changes
run: |
git config --global user.name "armadaproject-ci-bot"
git config --global user.email "armadaproject-ci-bot@users.noreply.github.com"
git status
git add .
git commit -m "updating armada-operator chart version"
git push
- name: Publish Helm chart
uses: stefanprodan/helm-gh-pages@master
with:
token: ${{ secrets.GITHUB_TOKEN }}
uses: G-Research/charts/.github/workflows/invoke-push.yaml@master
secrets:
APP_ID: ${{ secrets.APP_ID }}
APP_PRIVATE_KEY: ${{ secrets.APP_PRIVATE_KEY }}
41 changes: 8 additions & 33 deletions .github/workflows/release_rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
fi
release:
name: Release
needs: validate
runs-on: "ubuntu-22.04"
environment: armada-dockerhub

Expand All @@ -48,10 +49,10 @@ jobs:
with:
fetch-depth: 0

- name: Setup Golang with cache
- name: Setup Golang with Cache
uses: magnetikonline/action-golang-cache@v4
with:
go-version: ~1.20
go-version: "1.20"

- name: Set up Docker Buildx
id: buildx
Expand All @@ -63,44 +64,18 @@ jobs:
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"
version: v1.19.2
args: "-f ./.goreleaser.yaml release --snapshot --skip-sbom --skip-sign --clean"
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"

- name: Run Docker push script
run: ./scripts/docker-push.sh -t '${{ github.event.workflow_run.head_sha }}'
70 changes: 70 additions & 0 deletions scripts/docker-push.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
#!/bin/bash

docker_registry="gresearch"
docker_tag=""
image_names=(
"armada-operator"
)

print_usage() {
echo "Usage: $0 [-t|--tag <tag>] [-r|--registry <registry>]"
echo ""
echo "Options:"
echo " -t|--tag Docker tag (required)"
echo " -r|--registry Docker registry (default: 'gresearch')"
echo " -h|--help Display this help message"
}

# parse command-line arguments
while [[ $# -gt 0 ]]; do
case "$1" in
-t|--tag)
docker_tag=$2
shift
shift
;;
-r|--registry)
docker_registry=$2
shift
shift
;;
-h|--help)
print_usage
exit 0
;;
*)
echo "::error ::invalid argument $1" >&2
exit 1
;;
esac
done

# validate that docker_tag is provided
if [ -z "$docker_tag" ]; then
echo "::error ::docker tag is must be provided with -t|--tag option"
exit 1
fi

# iterate over image names, check existence and push them
for image_name in "${image_names[@]}"; do
full_image_name="${docker_registry}/${image_name}:${docker_tag}"
echo "checking existence of $full_image_name..."
# Check if the image with the tag exists
if ! docker image inspect "$full_image_name" > /dev/null 2>&1; then
echo "::error ::image $full_image_name does not exist locally"
exit 1
fi
done

echo "pushing Armada images to $docker_registry with tag $docker_tag..."

# iterate over image names and push them
for image_name in "${image_names[@]}"; do
full_image_name="${docker_registry}/${image_name}:${docker_tag}"
echo "pushing $full_image_name..."
docker push $full_image_name
if [ $? -ne 0 ]; then
echo "::error ::failed to push $full_image_name"
exit 1
fi
done
13 changes: 0 additions & 13 deletions scripts/update_chart.sh

This file was deleted.

0 comments on commit 1a54b9a

Please sign in to comment.