mirror of
https://github.com/komodorio/helm-dashboard.git
synced 2026-03-24 11:48:04 +00:00
168 lines
5.6 KiB
YAML
168 lines
5.6 KiB
YAML
name: release
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
env:
|
|
HELM_REP: helm-charts
|
|
GH_OWNER: komodorio
|
|
CHART_DIR: charts/helm-dashboard
|
|
|
|
jobs:
|
|
prepare:
|
|
name: prepare
|
|
outputs:
|
|
version: ${{ steps.version.outputs.version }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
- uses: actions/setup-go@v2
|
|
with:
|
|
go-version: "^1.17"
|
|
|
|
- name: Calculate next release version
|
|
id: version
|
|
run: |
|
|
echo ${{ secrets.GITHUB_TOKEN }} > token
|
|
gh auth login --with-token < token
|
|
go install github.com/davidrjonas/semver-cli@latest
|
|
commit=$(git log --format="%H" -n 1)
|
|
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:
|
|
name: release
|
|
needs: [prepare]
|
|
if: needs.prepare.outputs.version
|
|
outputs:
|
|
tag-name: ${{ steps.commit.outputs.tag-name }}
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
fetch-depth: 0
|
|
|
|
- name: Update plugin.yaml
|
|
uses: fjogeleit/yaml-update-action@main
|
|
with:
|
|
valueFile: plugin.yaml
|
|
propertyPath: version
|
|
value: ${{ needs.prepare.outputs.version }}
|
|
commitChange: false
|
|
|
|
- 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:
|
|
github_token: ${{ secrets.ADMIN_KOMI_GITHUB_TOKEN }}
|
|
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:
|
|
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
|
|
run: "dist/helm-dashboard_linux_amd64_v1/helm-dashboard --help"
|
|
|
|
image:
|
|
runs-on: ubuntu-latest
|
|
needs: [release, prepare]
|
|
timeout-minutes: 60
|
|
steps:
|
|
- name: Check out the repo
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Docker meta
|
|
uses: docker/metadata-action@v3
|
|
id: meta
|
|
with:
|
|
images: komodorio/helm-dashboard
|
|
|
|
- name: Login to DockerHub
|
|
uses: docker/login-action@v1
|
|
if: github.event_name != 'pull_request'
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USER }}
|
|
password: ${{ secrets.DOCKERHUB_PASS }}
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v2
|
|
if: github.event_name != 'pull_request'
|
|
with:
|
|
context: .
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
tags: komodorio/helm-dashboard:${{ needs.prepare.outputs.version }},komodorio/helm-dashboard:latest
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
build-args: VER=${{ needs.prepare.outputs.version }}
|
|
|
|
publish_chart:
|
|
runs-on: ubuntu-latest
|
|
needs: [release, image, prepare]
|
|
if: github.event_name == 'push' || github.event_name == 'workflow_dispatch'
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
with:
|
|
fetch-depth: 0
|
|
- name: Bump versions
|
|
run: |
|
|
git config user.email komi@komodor.io
|
|
git config user.name komodor-bot
|
|
git fetch --tags
|
|
git checkout main
|
|
sh ./ci/bump-versions.sh
|
|
git add charts/helm-dashboard/Chart.yaml
|
|
git commit -m "Increment chart versions [skip ci]" || echo "Already up-to-date"
|
|
git push -f || echo "Nothing to push!"
|
|
env:
|
|
APP_VERSION: ${{ needs.prepare.outputs.version }}
|
|
- name: Push folder to helm-charts repository
|
|
uses: crykn/copy_folder_to_another_repo_action@v1.0.6
|
|
env:
|
|
API_TOKEN_GITHUB: ${{ secrets.KOMI_WORKFLOW_TOKEN }}
|
|
with:
|
|
source_folder: "charts/helm-dashboard"
|
|
destination_repo: "komodorio/helm-charts"
|
|
destination_folder: "charts/helm-dashboard"
|
|
user_email: "komi@komodor.io"
|
|
user_name: "komodor-bot"
|
|
destination_branch: "master"
|
|
commit_msg: "feat(helm-dashboard): ${{ github.event.head_commit.message }}" #important!! don't change this commit message unless you change the condition in pipeline.yml on helm-charts repo
|