Skip to content

Merge pull request #149 from erikgb/resolve-ns-conflict #16

Merge pull request #149 from erikgb/resolve-ns-conflict

Merge pull request #149 from erikgb/resolve-ns-conflict #16

Workflow file for this run

name: Release
on:
push:
tags:
- 'v*'
jobs:
image:
name: Push Container Image
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- name: Build images
run: |
docker build -t accurate:dev .
- name: Login to ghcr.io
run: echo ${{ secrets.GITHUB_TOKEN }} | docker login ghcr.io -u $GITHUB_ACTOR --password-stdin
- name: Push images
run: |
TAG=${GITHUB_REF#refs/tags/v}
docker tag accurate:dev ghcr.io/cybozu-go/accurate:$TAG
docker push ghcr.io/cybozu-go/accurate:$TAG
release:
name: Release on GitHub
needs: image
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
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/accurate/releases/latest" | jq -r .tag_name)
echo "GORELEASER_PREVIOUS_TAG=${TAG}" >> $GITHUB_ENV
- name: GoReleaser
uses: goreleaser/goreleaser-action@f82d6c1c344bcacabba2c841718984797f664a6b # v4.2.0
with:
distribution: goreleaser
version: v1.15.2
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update new version in krew-index
uses: rajatjindal/krew-release-bot@92da038bbf995803124a8e50ebd438b2f37bbbb0 # v0.0.43
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 accurate https://cybozu-go.github.io/accurate
helm repo update
# get the release tag version
tag_version=${GITHUB_REF##*/v}
# get the latest chart version
chart_version=$(helm search repo accurate -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/accurate/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/accurate/Chart.yaml
sed --in-place "s/0-chart-patch-version-placeholder/$new_patch_version/g" charts/accurate/Chart.yaml
sed --in-place "s/app-version-placeholder/$tag_version/g" charts/accurate/values.yaml
- name: Create release notes
run: |
tag_version=${GITHUB_REF##*/}
cat <<EOF > ./charts/accurate/RELEASE.md
Helm chart for accurate [$tag_version](https://github.com/cybozu-go/accurate/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 }}"