Skip to content

Release

Release #282

Workflow file for this run

# Reference from:
# https://goreleaser.com/ci/actions/
name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+'
permissions:
contents: write
jobs:
Test:
name: Unit Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go 1.19
uses: actions/setup-go@v2
with:
go-version: 1.19
- name: Running go tests with coverage
env:
GO111MODULE: on
run: make cover
GolangLint:
name: Golang Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go 1.19
uses: actions/setup-go@v5
with:
go-version: 1.19
# NOTE: This golangci-lint action MUST be specified as v2 version, otherwise an error will be reported:
# Running error: can't run linter goanalysis_metalinter\nbuildssa: failed to load package main: could
# not load export data: no export data for \"k8s.io/kube-aggregator\"
- name: golangci-lint
uses: golangci/golangci-lint-action@v2
with:
version: v1.58.2
# # Lints Pull Request commits with commitlint.
# #
# # Rules can be referenced:
# # https://github.com/conventional-changelog/commitlint/tree/master/%40commitlint/config-conventional
CommitLint:
name: Commit Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: wagoid/commitlint-github-action@v5
# Release the artifacts, release note and images.
Release:
runs-on: ubuntu-latest
# needs: [Test, GolangLint, CommitLint]
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if on tag
run: |
if [[ "${GITHUB_REF#refs/tags/}" != "$GITHUB_REF" ]]; then
echo "Running on tag ${GITHUB_REF#refs/tags/}"
else
echo "Not running on a tag"
fi
- name: Get version
id: get_version
run: echo ::set-output name=VERSION::${GITHUB_REF/refs\/tags\//}
# - name: Determine GoReleaser Config with Regex
# run: |
# tag=${GITHUB_REF#refs/tags/}
# alpha='v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+'
# beta='v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+'
# rc='v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
# release='v[0-9]+.[0-9]+.[0-9]+'
# if [[ $tag =~ $alpha ]] || [[ $tag =~ $beta ]]; then
# echo "Match found for alpha or beta tag"
# echo "GO_RELEASER_CONFIG=.goreleaser-dev.yml" >> $GITHUB_ENV
# elif [[ $tag =~ $rc ]] || [[ $tag =~ $release ]]; then
# echo "Match found for rc or release tag"
# echo "GO_RELEASER_CONFIG=.goreleaser.yml" >> $GITHUB_ENV
# else
# echo "No match found"
# exit 1
# fi
- name: Get new chart version from the chart repo
id: get_chart_version
run: |
helm repo add kusionstack https://kusionstack.github.io/charts
helm repo update
version=$(helm search repo kusionstack/karpor --versions | head -n 2 | tail -n 1 | awk '{print $2}')
if [ -z "$version" ]; then
echo "Error: Unable to fetch chart version" >&2
exit 1
fi
echo "Current chart version is: $version"
major=$(echo "$version" | cut -d. -f1)
minor=$(echo "$version" | cut -d. -f2)
patch=$(echo "$version" | cut -d. -f3)
new_chart_version="${major}.${minor}.$((patch + 1))"
echo "New chart version is: $new_chart_version"
echo "::set-output name=new_chart_version::$new_chart_version"
- name: Checkout Target repository
uses: actions/checkout@v3
with:
repository: KusionStack/charts
path: charts
token: ${{ secrets.GITHUB_TOKEN }}
- name: Bump version in the related HelmChart Chart.yaml
uses: fjogeleit/yaml-update-action@main
with:
repository: KusionStack/charts
valueFile: 'charts/karpor/Chart.yaml'
changes: '{"version":"${{ steps.get_chart_version.outputs.new_chart_version }}", "appVersion":"${{ steps.get_version.outputs.VERSION }}"}'
value: ${{ steps.get_version.outputs.VERSION }}
branch: bump-karpor-to-${{ steps.get_version.outputs.VERSION }}
targetBranch: chart-version-updater
createPR: false
message: 'refactor: bump karpor version to ${{ steps.get_version.outputs.VERSION }}'
token: ${{ secrets.GITHUB_TOKEN }}
workDir: charts
- name: Log Test Outputs # Log outputs for debugging
run: |
echo "Testing complete. Check the logs for details."
echo "New chart version: ${{ steps.get_chart_version.outputs.new_chart_version }}"
echo "App version: ${{ steps.get_version.outputs.VERSION }}"