Skip to content

Commit

Permalink
TENT-5976 Introduce *-dev versions in code and establish a Branch Of…
Browse files Browse the repository at this point in the history
…f Major Version script
  • Loading branch information
sebastianbarth-disy committed Nov 5, 2024
1 parent 3d2080c commit 047d21c
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 32 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/branchOffCadenzaVersion.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Branch off Cadenza Version

on:
workflow_dispatch:
inputs:
cadenza-version:
type: string
required: true
description: |
Next Cadenza Main Version
(e.g. '10.2' for setting `main` branch version to 10.2.0-dev as corresponding major-minor version of in Cadenza 10.2.)
jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Validate version input
if: "${{ github.event.inputs.cadenza-version != '' }}"
run: |
if ! [[ '${{ github.event.inputs.cadenza-version }}' =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "Cadenza Version must be specified in the format x.x (e.g. 10.2). Was '${{ github.event.inputs.cadenza-version }}'." >&2
exit 1
fi
- uses: actions/create-github-app-token@v1
id: app-token
with:
app-id: ${{ vars.DISY_RELEASE_APP_ID }}
private-key: ${{ secrets.DISY_RELEASE_APP_SECRET }}
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.app-token.outputs.token }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version-file: package.json
cache: 'npm'

# Needed for creating the tag
- name: Configure Git
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Determine branch name
run: echo "BRANCH_NAME=v$(npm pkg get version | tr -d \" | cut -d. -f1,2).x" >> $GITHUB_ENV

- name: Create branch for current version
run: git branch ${{ env.BRANCH_NAME }} main

- name: Bump package version of main
run: echo "NEW_VERSION=$(npm --no-git-tag-version version ${{ github.event.inputs.cadenza-version }}.0-dev)" >> $GITHUB_ENV

- name: Commit and tag changes
run: |
git add "package.json"
git commit -m "chore: branch off main as ${{ env.BRANCH_NAME }} and bump main version to ${{ env.NEW_VERSION }}"
- name: Push changes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: git push -u origin ${{ env.BRANCH_NAME }} && git push origin && git push --tags
51 changes: 22 additions & 29 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,13 @@
name: Release

on:
workflow_dispatch:
inputs:
cadenza-version:
type: string
description: |
Cadenza Main Version
(e.g. '10.2'; Required only to create a new *.0 release, e.g. 10.2.0 for Cadenza 10.2. Otherwise the current version is incremented)
workflow_dispatch

jobs:
release:
runs-on: ubuntu-latest

steps:
- name: Validate version input
if: "${{ github.event.inputs.cadenza-version != '' }}"
run: |
if ! [[ '${{ github.event.inputs.cadenza-version }}' =~ ^[0-9]+\.[0-9]+$ ]]; then
echo "Cadenza Version must be specified in the format x.x (e.g. 10.2). Was '${{ github.event.inputs.cadenza-version }}'." >&2
exit 1
fi
- uses: actions/create-github-app-token@v1
id: app-token
with:
Expand All @@ -49,13 +34,10 @@ jobs:
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
- name: Bump package version
if: "${{ github.event.inputs.cadenza-version == '' }}"
run: echo "NEW_VERSION=$(npm --no-git-tag-version version patch)" >> $GITHUB_ENV

- name: Bump package version (Cadenza main version release)
if: "${{ github.event.inputs.cadenza-version != '' }}"
run: echo "NEW_VERSION=$(npm --no-git-tag-version version ${{ github.event.inputs.cadenza-version }}.0)" >> $GITHUB_ENV
- name: Prepare package version (e.g. 1.2.3-dev => 1.2.3)
run: |
npm --no-git-tag-version version patch # Remove -dev suffix
echo "RELEASE_VERSION=$(npm pkg get version | tr -d \")" >> $GITHUB_ENV # Determine RELEASE_VERSION
- name: Set release tag to 'latest'
run: echo "RELEASE_TAG=latest" >> $GITHUB_ENV
Expand All @@ -65,15 +47,26 @@ jobs:
uses: superfaceai/release-changelog-action@v2
with:
path-to-changelog: CHANGELOG.md
version: ${{ env.NEW_VERSION }}
version: ${{ env.RELEASE_VERSION }}
operation: release

- name: Commit and tag changes
- name: Commit release and tag it
run: |
git add "package.json"
git add "CHANGELOG.md"
git commit -m "chore: release ${{ env.NEW_VERSION }}"
git tag ${{ env.NEW_VERSION }}
git commit -m "chore: release ${{ env.RELEASE_VERSION }}"
git tag ${{ env.RELEASE_VERSION }}
- name: Bump package version to new dev version (e.g. 1.2.3 => 1.2.4-dev)
run: |
npm --no-git-tag-version version patch # Determine next release version
DEV_VERSION=$(npm pkg get version | tr -d \")-dev && echo "DEV_VERSION=$DEV_VERSION" >> $GITHUB_ENV # Determine DEV_VERSION with -dev suffix
npm --no-git-tag-version version $DEV_VERSION # Set main to NEW_VERISON
- name: Commit version bump
run: |
git add "package.json"
git commit -m "chore: bump up version to ${{ env.DEV_VERSION }}"
- name: Push changes
env:
Expand All @@ -85,13 +78,13 @@ jobs:
uses: superfaceai/release-changelog-action@v2
with:
path-to-changelog: CHANGELOG.md
version: ${{ env.NEW_VERSION }}
version: ${{ env.RELEASE_VERSION }}
operation: read

- name: Update GitHub release documentation
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ env.NEW_VERSION }}
tag_name: ${{ env.RELEASE_VERSION }}
body: ${{ steps.get-changelog.outputs.changelog }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@disy/cadenza.js",
"version": "10.2.2",
"version": "10.2.3-dev",
"license": "Apache-2.0",
"repository": "github:DisyInformationssysteme/cadenza.js",
"type": "module",
Expand Down

0 comments on commit 047d21c

Please sign in to comment.