Merge pull request #129 from cybozu-go/remove-renovate #18
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*' | |
jobs: | |
release: | |
runs-on: ubuntu-22.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- uses: docker/setup-qemu-action@v2 | |
- uses: docker/setup-buildx-action@v2 | |
- name: GHCR Login | |
uses: docker/login-action@v2 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: quay.io Login | |
uses: docker/login-action@v2 | |
with: | |
registry: quay.io | |
username: ${{ secrets.QUAY_USER }} | |
password: ${{ secrets.QUAY_PASSWORD }} | |
- name: Setup go | |
uses: actions/setup-go@v3 | |
with: | |
go-version-file: go.mod | |
- 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/pod-security-admission/releases/latest" | jq -r .tag_name) | |
echo "GORELEASER_PREVIOUS_TAG=${TAG}" >> $GITHUB_ENV | |
- name: GoReleaser | |
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0 | |
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@v3 | |
with: | |
fetch-depth: 0 | |
- name: Install Helm | |
uses: azure/setup-helm@5119fcb9089d432beecbf79bb2c7915207344b78 # v3.5 | |
- name: Set chart version | |
run: | | |
helm repo add pod-security-admission https://cybozu-go.github.io/pod-security-admission | |
helm repo update | |
# get the release tag version | |
tag_version=${GITHUB_REF##*/v} | |
# get the latest chart version | |
chart_version=$(helm search repo pod-security-admission -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/pod-security-admission/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/pod-security-admission/Chart.yaml | |
sed --in-place "s/0-chart-patch-version-placeholder/$new_patch_version/g" charts/pod-security-admission/Chart.yaml | |
sed --in-place "s/app-version-placeholder/$tag_version/g" charts/pod-security-admission/values.yaml | |
- name: Create release notes | |
run: | | |
tag_version=${GITHUB_REF##*/} | |
cat <<EOF > ./charts/pod-security-admission/RELEASE.md | |
Helm chart for pod-security-admission [$tag_version](https://github.com/cybozu-go/pod-security-admission/releases/tag/$tag_version) | |
EOF | |
- name: Configure Git | |
run: | | |
git config user.name "$GITHUB_ACTOR" | |
git config user.email "$GITHUB_ACTOR@users.noreply.github.com" | |
- name: Run chart-releaser | |
uses: helm/chart-releaser-action@be16258da8010256c6e82849661221415f031968 # v1.5.0 | |
with: | |
config: cr.yaml | |
env: | |
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |