Skip to content

publish release

publish release #1

Workflow file for this run

name: publish release
on:
workflow_dispatch:
inputs:
part:
description: "Semver part to bump (major, minor, patch)"
type: choice
required: true
default: "patch"
options: ["major", "minor", "patch"]
dry-run:
description: "Dry run"
type: boolean
required: true
default: false
skip-tests:
description: "Skip tests"
type: boolean
required: true
default: false
workflow_call:
inputs:
part:
description: "Semver part to bump (major, minor, patch)"
type: string
required: false
default: "patch"
dry-run:
description: "Dry run"
type: boolean
required: false
default: false
jobs:
release:
name: Bump version
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
outputs:
VERSION: ${{ steps.get-version.outputs.VERSION }}
SHORT_VERSION: ${{ steps.get-version.outputs.SHORT_VERSION }}
MAJOR_VERSION: ${{ steps.get-version.outputs.MAJOR_VERSION }}
MINOR_VERSION: ${{ steps.get-version.outputs.MINOR_VERSION }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Get tags
run: git fetch --tags origin
- name: Configure git for github-actions[bot]
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
- name: Install Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install bumpversion
run: pip install bumpversion
- name: Bump version with bumpversion
run: |
bumpversion ${{ inputs.part || github.event.inputs.part }}
- name: Get version
id: get-version
run: |
version="$(git describe --tags)"
# remove the leading v from version
version="${version:1}"
echo "VERSION=$version" >> $GITHUB_OUTPUT
major_version="$(cut -d '.' -f 1 <<< $version)"
echo "MAJOR_VERSION=$major_version" >> $GITHUB_OUTPUT
minor_version="$(cut -d '.' -f 2 <<< $version)"
echo "MINOR_VERSION=$minor_version" >> $GITHUB_OUTPUT
short_version="$major_version.$minor_version"
echo "SHORT_VERSION=$short_version" >> $GITHUB_OUTPUT
- name: Show short version
run: echo ${{ steps.get-version.outputs.SHORT_VERSION }}
- name: Commit and push with tags
if: ${{ (inputs.dry-run == false) || (github.event.inputs.dry-run == 'false') }}
run: |
git pull --rebase origin master
git push --follow-tags
- name: Create GitHub Release
if: ${{ (inputs.dry-run == false) || (github.event.inputs.dry-run == 'false') }}
uses: softprops/action-gh-release@v2
with:
tag_name: v${{ steps.get-version.outputs.VERSION }}
name: Release v${{ steps.get-version.outputs.VERSION }}
body: |
## AnnotationEngine v${{ steps.get-version.outputs.VERSION }}
This release was automatically generated by the release workflow.
### Changes
- Version bumped from previous release
See commit history for detailed changes.
draft: false
prerelease: false
update-chart:
name: Update annotationengine Helm chart
runs-on: ubuntu-latest
needs: release
if: ${{ (inputs.dry-run == false) || (github.event.inputs.dry-run == 'false') }}
permissions:
contents: read
id-token: write
steps:
- name: Checkout AnnotationEngine repo
uses: actions/checkout@v4
- name: Checkout cave-helm-charts repo
uses: actions/checkout@v4
with:
repository: CAVEconnectome/cave-helm-charts
token: ${{ secrets.HELM_CHART_UPDATE_TOKEN }}
path: helm-charts
- name: Update Chart.yaml appVersion
id: update-chart
run: |
cd helm-charts
chart_file="charts/annotationengine/Chart.yaml"
# Update both appVersion and chart version to match application version
sed -i "s/^appVersion: .*/appVersion: \"${{ needs.release.outputs.VERSION }}\"/" $chart_file
sed -i "s/^version: .*/version: ${{ needs.release.outputs.VERSION }}/" $chart_file
echo "Updated chart version to: ${{ needs.release.outputs.VERSION }}"
echo "Updated app version to: ${{ needs.release.outputs.VERSION }}"
echo "CHART_VERSION=${{ needs.release.outputs.VERSION }}" >> $GITHUB_OUTPUT
- name: Commit and push changes
run: |
cd helm-charts
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add charts/annotationengine/Chart.yaml
git commit -m "Update annotationengine to v${{ needs.release.outputs.VERSION }}
- Update appVersion to ${{ needs.release.outputs.VERSION }}
- Update chart version to ${{ needs.release.outputs.VERSION }}
Auto-generated by AnnotationEngine release workflow"
git push