Setup release workflow (#198) #1
Workflow file for this run
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 | |
on: | |
push: | |
tags: | |
- "v*" | |
permissions: read-all | |
jobs: | |
build-and-publish-images: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Login to AWS Public ECR | |
uses: docker/login-action@v3 | |
with: | |
registry: public.ecr.aws | |
username: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
password: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
- name: Extract tag name | |
id: extract_tag_name | |
run: echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT | |
- name: Build and push clowarden-dbmigrator image | |
run: | | |
docker build \ | |
-f database/migrations/Dockerfile \ | |
-t public.ecr.aws/g6m3a0y9/clowarden-dbmigrator:${{steps.extract_tag_name.outputs.tag}} \ | |
-t public.ecr.aws/g6m3a0y9/clowarden-dbmigrator:latest \ | |
. | |
docker push --all-tags public.ecr.aws/g6m3a0y9/clowarden-dbmigrator | |
- name: Build and push clowarden-server image | |
run: | | |
docker build \ | |
-t public.ecr.aws/g6m3a0y9/clowarden-server:${{steps.extract_tag_name.outputs.tag}} \ | |
-t public.ecr.aws/g6m3a0y9/clowarden-server:latest \ | |
. | |
docker push --all-tags public.ecr.aws/g6m3a0y9/clowarden-server | |
package-and-publish-helm-chart: | |
needs: | |
- build-and-publish-images | |
permissions: | |
contents: write | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "[email protected]" | |
- name: Install Helm | |
uses: azure/setup-helm@v4 | |
- name: Run chart-releaser | |
run: | | |
# From: https://github.com/metallb/metallb/blob/293f43c1f78ab1b5fa8879a76746b094bd9dd3ca/.github/workflows/publish.yaml#L134-L163 | |
# Ref: https://github.com/helm/chart-releaser-action/issues/60 | |
curl -sSLo cr.tar.gz "https://github.com/helm/chart-releaser/releases/download/v1.6.1/chart-releaser_1.6.1_linux_amd64.tar.gz" | |
tar -xzf cr.tar.gz | |
rm -f cr.tar.gz | |
repo=$(basename "$GITHUB_REPOSITORY") | |
owner=$(dirname "$GITHUB_REPOSITORY") | |
tag="${GITHUB_REF_NAME:1}" | |
exists=$(curl -s -H "Accept: application/vnd.github.v3+json" https://github.com/$GITHUB_REPOSITORY/releases/tag/$repo-chart-$tag -w %{http_code} -o /dev/null) | |
if [[ $exists != "200" ]]; then | |
echo "Creating release..." | |
# package chart | |
./cr package charts/$repo | |
# upload chart to github releases | |
./cr upload \ | |
--owner "$owner" \ | |
--git-repo "$repo" \ | |
--release-name-template "{{ .Name }}-chart-{{ .Version }}" \ | |
--token "${{ secrets.GITHUB_TOKEN }}" | |
# Update index and push to github pages | |
./cr index \ | |
--owner "$owner" \ | |
--git-repo "$repo" \ | |
--index-path index.yaml \ | |
--release-name-template "{{ .Name }}-chart-{{ .Version }}" \ | |
--push | |
else | |
echo "Release already exists" | |
fi |