From a73c0052975b1de1ddd89b7cb8bd15c2313d4749 Mon Sep 17 00:00:00 2001 From: Sebastian Barth Date: Fri, 11 Oct 2024 10:00:48 +0200 Subject: [PATCH] TENT-5945 feat: Switch from semver to Cadenza version based versioning (#48) --- .github/workflows/release-legacy.yml | 97 ++++++++++++++++++++++++++++ .github/workflows/release.yml | 37 +++++++---- CHANGELOG.md | 6 +- src/docs.md | 9 ++- 4 files changed, 133 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/release-legacy.yml diff --git a/.github/workflows/release-legacy.yml b/.github/workflows/release-legacy.yml new file mode 100644 index 00000000..4c895784 --- /dev/null +++ b/.github/workflows/release-legacy.yml @@ -0,0 +1,97 @@ +# This workflow should only be used for Semantic versioning based releases of Cadenza JS versions used in Cadenza 10.1 +# and earlier. Starting with 10.2 we do not use Semantic versioning in the classic way. + +name: Legacy Release (Cadenza 10.1 and earlier) + +on: + workflow_dispatch: + inputs: + release-type: + type: choice + description: 'Release type' + required: true + options: + - patch + - minor + - major + default: 'patch' + + +jobs: + release: + runs-on: ubuntu-latest + + steps: + - 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' + + - run: npm ci + - run: npm test + - run: npm run build + + # 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: Bump package version + run: | + echo "NEW_VERSION=$(npm --no-git-tag-version version ${{ github.event.inputs.release-type }})" >> $GITHUB_ENV + echo "RELEASE_TAG=latest" >> $GITHUB_ENV + + # Update changelog unreleased section with new version + - name: Update changelog + uses: superfaceai/release-changelog-action@v2 + with: + path-to-changelog: CHANGELOG.md + version: ${{ env.NEW_VERSION }} + operation: release + + - name: Commit and tag changes + run: | + git add "package.json" + git add "CHANGELOG.md" + git commit -m "chore: release ${{ env.NEW_VERSION }}" + git tag ${{ env.NEW_VERSION }} + + - name: Push changes + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: git push origin && git push --tags + + - id: get-changelog + name: Get version changelog + uses: superfaceai/release-changelog-action@v2 + with: + path-to-changelog: CHANGELOG.md + version: ${{ env.NEW_VERSION }} + operation: read + + - name: Update GitHub release documentation + uses: softprops/action-gh-release@v1 + with: + tag_name: ${{ env.NEW_VERSION }} + body: ${{ steps.get-changelog.outputs.changelog }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Publish npm package + run: | + npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}" + npm publish --verbose --access=public --tag=${{ env.RELEASE_TAG }} + env: + NPM_TOKEN: ${{ secrets.NPMJS_ACCESS_TOKEN }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b6725127..36579719 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,17 +1,16 @@ +# This workflow should only be used for version releases for Cadenza JS versions bundled with +# Cadenza 10.2 and later. For earlier versions use the "Legacy Release" workflow. + name: Release on: workflow_dispatch: inputs: - release-type: - type: choice - description: 'Release type' - required: true - options: - - patch - - minor - - major - default: 'patch' + cadenza-version: + type: string + description: | + Cadenza Main Version + (Required only to create a new .0 release (e.g. 10.2.0). Otherwise the current version is incremented.)' jobs: @@ -19,6 +18,14 @@ jobs: 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: @@ -46,9 +53,15 @@ jobs: git config --global user.name "github-actions[bot]" - name: Bump package version - run: | - echo "NEW_VERSION=$(npm --no-git-tag-version version ${{ github.event.inputs.release-type }})" >> $GITHUB_ENV - echo "RELEASE_TAG=latest" >> $GITHUB_ENV + 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=${{ github.event.inputs.cadenza-version }}.0" >> $GITHUB_ENV + + - name: Set release tag to 'latest' + run: echo "RELEASE_TAG=latest" >> $GITHUB_ENV # Update changelog unreleased section with new version - name: Update changelog diff --git a/CHANGELOG.md b/CHANGELOG.md index 078f4e9a..8447870d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,12 @@ # Changelog All notable changes to this project will be documented in this file. -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). +This project uses a version scheme based on the Cadenza main version in the format x.x.y, where x.x is the Cadenza main version and y a functional change or bugfix. ## Unreleased +### Changed +- Base the version scheme on the Cadenza main version (starting with Cadenza 10.2). New versions have the format x.x.y, where x.x is the Cadenza main version and y a functional change or bugfix. ## 2.13.2 - 2024-10-10 ### Added diff --git a/src/docs.md b/src/docs.md index dcf2d72a..2531162e 100644 --- a/src/docs.md +++ b/src/docs.md @@ -10,12 +10,17 @@ Cadenza JS is a JavaScript library to use the [disy Cadenza](https://www.disy.ne Cadenza JS is included in the Cadenza distribution in the corresponding version. -Alternatively you can install the most recent version using npm: +Alternatively you can install the most recent version for a particular Cadenza Release using npm: ```bash -npm install @disy/cadenza.js +npm install @disy/cadenza.js@~10.2.0 # For latest version for Cadenza 10.2 ``` +The Cadenza main version is reflected in the corresponding major and minor version of Cadenza JS (e.g. 10.2.0 for Cadenza 10.2), while the last version segment is increased for both, bugfixes and functional changes. + +### Cadenza 10.1 and earlier +For Cadenza 10.1 and earlier versions Cadenza JS used did use genuine semantic versioning. Please consult the Cadenza Documentation for the corresponding major and minor version of cadenza.js. + ## Usage Examples This section features usage examples for Cadenza JS. For detailed usage information, see the "API:" links.