mirror of
https://github.com/kerberos-io/agent.git
synced 2026-08-23 15:08:32 +00:00
Merge pull request #282 from kerberos-io/feature/add-bump-release-workflow
feature/add-bump-release-workflow
This commit is contained in:
68
.github/workflows/release-bump.yml
vendored
Normal file
68
.github/workflows/release-bump.yml
vendored
Normal file
@@ -0,0 +1,68 @@
|
||||
name: Bump release
|
||||
|
||||
# Manually "promote" the agent to a new release.
|
||||
# Pick which part of the semantic version to bump, this workflow computes the
|
||||
# next vMAJOR.MINOR.PATCH tag, pushes it and triggers the existing
|
||||
# release-create pipeline to build and publish the images and GitHub release.
|
||||
on:
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
bump:
|
||||
description: "Which part of the version to bump"
|
||||
required: true
|
||||
default: patch
|
||||
type: choice
|
||||
options:
|
||||
- major
|
||||
- minor
|
||||
- patch
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
actions: write
|
||||
|
||||
jobs:
|
||||
bump-release:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
fetch-tags: true
|
||||
|
||||
- name: Compute next version
|
||||
id: version
|
||||
run: |
|
||||
set -euo pipefail
|
||||
latest=$(git tag --list 'v[0-9]*.[0-9]*.[0-9]*' --sort=-v:refname | head -n1)
|
||||
latest=${latest:-v0.0.0}
|
||||
echo "Latest tag: $latest"
|
||||
version=${latest#v}
|
||||
IFS='.' read -r major minor patch <<< "$version"
|
||||
case "${{ github.event.inputs.bump }}" in
|
||||
major) major=$((major + 1)); minor=0; patch=0 ;;
|
||||
minor) minor=$((minor + 1)); patch=0 ;;
|
||||
patch) patch=$((patch + 1)) ;;
|
||||
esac
|
||||
next="v${major}.${minor}.${patch}"
|
||||
echo "Next tag: $next"
|
||||
echo "tag=$next" >> "$GITHUB_OUTPUT"
|
||||
|
||||
- name: Create and push tag
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
git tag -a "${{ steps.version.outputs.tag }}" -m "Release ${{ steps.version.outputs.tag }}"
|
||||
git push origin "${{ steps.version.outputs.tag }}"
|
||||
|
||||
# A tag pushed with the default GITHUB_TOKEN does not trigger other
|
||||
# workflows, so invoke the release pipeline explicitly for the new tag.
|
||||
- name: Trigger release pipeline
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
run: |
|
||||
gh workflow run release-create.yml \
|
||||
--ref "${{ steps.version.outputs.tag }}" \
|
||||
-f tag="${{ steps.version.outputs.tag }}"
|
||||
Reference in New Issue
Block a user