Update release workflow (#202)

* Update release workflow

* Update release workflow

* Change label
This commit is contained in:
ronahk
2023-01-26 16:12:51 +02:00
committed by GitHub
parent 7e32008bfe
commit 2df533ab5b
2 changed files with 82 additions and 39 deletions

2
.github/labeler.yml vendored
View File

@@ -50,7 +50,7 @@ github-actions:
- .github/pull_request_template - .github/pull_request_template
- .github/workflow/pull-request-labeler.yaml - .github/workflow/pull-request-labeler.yaml
release: publish:
- .github/workflows/publish-chart.yaml - .github/workflows/publish-chart.yaml
- .github/workflows/release.yaml - .github/workflows/release.yaml
- .goreleaser.yml - .goreleaser.yml

View File

@@ -2,8 +2,7 @@ name: release
on: on:
push: push:
tags: branches: [main]
- "v*"
env: env:
HELM_REP: helm-charts HELM_REP: helm-charts
@@ -11,56 +10,100 @@ env:
CHART_DIR: charts/helm-dashboard CHART_DIR: charts/helm-dashboard
jobs: jobs:
pre_release: prepare:
name: prepare
outputs:
version: ${{ steps.version.outputs.version }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - uses: actions/checkout@v3
uses: actions/checkout@v3 - uses: actions/setup-go@v2
with: with:
fetch-depth: 0 go-version: "^1.17"
- name: Get plugin version
id: get_plugin_version - name: Calculate next release version
run: echo "PLUGIN_VERSION=$(cat plugin.yaml | grep "version" | cut -d '"' -f 2)" >> $GITHUB_OUTPUT id: version
- name: Get tag name run: |
id: get_tag_name echo ${{ secrets.GITHUB_TOKEN }} > token
run: echo "TAG_NAME=$(echo ${{ github.ref_name }} | cut -d 'v' -f2)" >> $GITHUB_OUTPUT gh auth login --with-token < token
outputs: go install github.com/davidrjonas/semver-cli@latest
plugin_version: ${{ steps.get_plugin_version.outputs.PLUGIN_VERSION }} commit=$(git log --format="%H" -n 1)
release_tag: ${{ steps.get_tag_name.outputs.TAG_NAME }} last_pr=$(gh api -X GET search/issues -f q="repo:${{ github.repository }} is:closed is:pr sort:created-desc $commit" --jq '.items[0].number')
if [[ $last_pr = "" ]]; then echo "No pull request found" && exit 0; fi;
bump=$(gh pr view $last_pr --json labels --jq '.labels | map(select(.name | contains("release")) | .name) | .[0]' | sed s/release-//g)
if ! [[ "$bump" =~ ^(major|minor|patch) ]]; then echo "Not a release commit" && exit 0; fi;
echo $bump > bump.txt
cat bump.txt
current=$(gh release list | awk '{print $1}' | awk 'NR==1' | sed s/v//g)
next_version=$(semver-cli inc $bump $current)
echo "next_version is now $next_version"
echo "::set-output name=version::$next_version"
release: release:
needs: pre_release name: release
needs: [prepare]
if: needs.prepare.outputs.version
outputs:
tag-name: ${{ steps.commit.outputs.tag-name }}
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Plugin version/Tag name Check - uses: actions/checkout@v3
if: needs.pre_release.outputs.release_tag != needs.pre_release.outputs.plugin_version
uses: actions/github-script@v3
with:
script: |
core.setFailed('Plugin version and tag name are not equivalent!')
- name: Checkout
uses: actions/checkout@v3
with: with:
persist-credentials: false
fetch-depth: 0 fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v3 - name: Update plugin.yaml
uses: fjogeleit/yaml-update-action@main
with: with:
go-version: 1.18 valueFile: plugin.yaml
- name: git cleanup propertyPath: version
run: git clean -f value: ${{ needs.prepare.outputs.version }}
- name: Run GoReleaser commitChange: false
uses: goreleaser/goreleaser-action@v2
- name: Commit files
id: commit
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add -A
git commit -m "bumping release v${{ needs.prepare.outputs.version }} [skip ci]"
tag_name=v${{ needs.prepare.outputs.version }}
git tag $tag_name
echo "::set-output name=tag-name::$tag_name"
- name: Push changes
uses: ad-m/github-push-action@v0.6.0
with: with:
version: latest github_token: ${{ secrets.ADMIN_KOMI_GITHUB_TOKEN }}
args: release --rm-dist branch: ${{ github.ref }}
tags: true
- name: Changelog
uses: Bullrich/generate-release-changelog@master
id: changelog
env:
REPO: ${{ github.repository }}
- name: Create GitHub Release
uses: actions/create-release@v1
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.commit.outputs.tag-name }}
release_name: ${{ steps.commit.outputs.tag-name }}
body: ${{ steps.changelog.outputs.changelog }}
draft: false
prerelease: false
- name: Test Binary Versions - name: Test Binary Versions
run: "dist/helm-dashboard_linux_amd64_v1/helm-dashboard --help" run: "dist/helm-dashboard_linux_amd64_v1/helm-dashboard --help"
image: image:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [release, pre_release] needs: [release, prepare]
timeout-minutes: 60 timeout-minutes: 60
steps: steps:
- name: Check out the repo - name: Check out the repo
@@ -85,13 +128,13 @@ jobs:
with: with:
context: . context: .
push: ${{ github.event_name != 'pull_request' }} push: ${{ github.event_name != 'pull_request' }}
tags: komodorio/helm-dashboard:${{ needs.pre_release.outputs.release_tag }},komodorio/helm-dashboard:latest tags: komodorio/helm-dashboard:${{ needs.prepare.outputs.version }},komodorio/helm-dashboard:latest
labels: ${{ steps.meta.outputs.labels }} labels: ${{ steps.meta.outputs.labels }}
build-args: VER=${{ needs.pre_release.outputs.release_tag }} build-args: VER=${{ needs.prepare.outputs.version }}
publish_chart: publish_chart:
runs-on: ubuntu-latest runs-on: ubuntu-latest
needs: [image, pre_release] needs: [release, image, prepare]
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
steps: steps:
- name: Checkout - name: Checkout
@@ -109,7 +152,7 @@ jobs:
git commit -m "Increment chart versions [skip ci]" || echo "Already up-to-date" git commit -m "Increment chart versions [skip ci]" || echo "Already up-to-date"
git push -f || echo "Nothing to push!" git push -f || echo "Nothing to push!"
env: env:
APP_VERSION: ${{ needs.pre_release.outputs.release_tag }} APP_VERSION: ${{ needs.prepare.outputs.version }}
- name: Push folder to helm-charts repository - name: Push folder to helm-charts repository
uses: crykn/copy_folder_to_another_repo_action@v1.0.6 uses: crykn/copy_folder_to_another_repo_action@v1.0.6
env: env: