Skip to content

Merge pull request #61 from cybozu-go/delegated-namespaces #16

Merge pull request #61 from cybozu-go/delegated-namespaces

Merge pull request #61 from cybozu-go/delegated-namespaces #16

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
jobs:
release:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- name: GHCR Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: true
- uses: ./.github/actions/aqua
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Set previous release tag for GoReleaser
run: |
export TAG=$(curl -s "https://api.github.com/repos/cybozu-go/cattage/releases/latest" | jq -r .tag_name)
echo "GORELEASER_PREVIOUS_TAG=${TAG}" >> $GITHUB_ENV
- name: GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
chart-release:
runs-on: ubuntu-22.04
needs: release
if: contains(needs.release.result, 'success')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Helm
uses: azure/setup-helm@v4
- name: Set chart version
run: |
helm repo add cattage https://cybozu-go.github.io/cattage
helm repo update
# get the release tag version
tag_version=${GITHUB_REF##*/v}
# get the latest chart version
chart_version=$(helm search repo cattage -o json | jq -r 'sort_by(.version) | .[-1].version')
chart_patch_version=${chart_version##*.}
new_patch_version=$(($chart_patch_version+1))
# if minor or major version changed, reset new patch version
local_version=$(cat charts/cattage/Chart.yaml | yq .version | sed "s/0-chart-patch-version-placeholder/$chart_patch_version/g")
[ "$local_version" != "$chart_version" ] && new_patch_version=0
# replace placeholder with new version
sed --in-place "s/app-version-placeholder/$tag_version/g" charts/cattage/Chart.yaml
sed --in-place "s/0-chart-patch-version-placeholder/$new_patch_version/g" charts/cattage/Chart.yaml
sed --in-place "s/app-version-placeholder/$tag_version/g" charts/cattage/values.yaml
- name: Create release notes
run: |
tag_version=${GITHUB_REF##*/}
cat <<EOF > ./charts/cattage/RELEASE.md
Helm chart for cattage [$tag_version](https://github.com/cybozu-go/cattage/releases/tag/$tag_version)
EOF
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Run chart-releaser
uses: helm/chart-releaser-action@be16258da8010256c6e82849661221415f031968 # v1.5.0
with:
config: cr.yaml
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"