From b7f1f841d02251b058bc39715ea94e5e76911bd8 Mon Sep 17 00:00:00 2001 From: Ruben Romero Montes Date: Thu, 22 May 2025 13:37:09 +0200 Subject: [PATCH 1/2] chore(ci): update workflow triggers for releases Signed-off-by: Ruben Romero Montes --- .github/workflows/pr.yml | 1 + .github/workflows/release.yml | 30 +++++++++++------------------- .github/workflows/stage.yml | 9 ++++++++- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 8b15a69..79dba4a 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -5,6 +5,7 @@ on: pull_request: branches: - main + - 'release/*' concurrency: group: ${{ github.workflow }}-${{ github.ref }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e25662e..8c6399f 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -9,23 +9,21 @@ env: on: workflow_dispatch: - pull_request_target: - types: - - closed - branches: - - 'main' - paths: - - "src/**" - - "package-lock.json" - - "package.json" - - "tsconfig.json" - - ".github/workflows/release.yml" + inputs: + version_type: + description: 'Type of version bump' + required: true + default: 'patch' + type: choice + options: + - patch + - minor + - major jobs: release: runs-on: ubuntu-latest environment: staging - if: github.repository_owner == 'trustification' && github.event.pull_request.merged == true && startsWith(github.head_ref, 'release/' ) name: Release the project steps: - name: Checkout sources @@ -65,15 +63,9 @@ jobs: echo "oldest-tag=$(git for-each-ref --sort=creatordate --format '%(refname:lstrip=2)' refs/tags | grep ${{ steps.last-release.outputs.base-tag }} | head -n 1)" >> "$GITHUB_OUTPUT" - name: determine semver component to bump - env: - BUMP_PART: ${{ contains(github.event.pull_request.title,'major') && 'major' || 'check-minor' }} id: bump-decision run: | - if [[ $BUMP_PART == 'check-minor' ]]; then - echo "bump-part=${{ contains(github.event.pull_request.title,'minor') && 'minor' || 'patch' }}" >> "$GITHUB_OUTPUT" - else - echo "bump-part=major" >> "$GITHUB_OUTPUT" - fi + echo "bump-part=${{ github.event.inputs.version_type }}" >> "$GITHUB_OUTPUT" - name: Update package with new version id: bump diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml index e39d590..c62dad5 100644 --- a/.github/workflows/stage.yml +++ b/.github/workflows/stage.yml @@ -14,6 +14,7 @@ on: branches: - main + - 'release/*' paths: - "src/**" @@ -94,7 +95,13 @@ jobs: - name: Update package with new version id: bump run: | - echo "version=$(npm version prerelease --no-git-tag-version --preid ea)" >> "$GITHUB_OUTPUT" + if [[ "${{ github.base_ref }}" =~ ^release/([0-9]+\.[0-9]+)\.x$ ]]; then + # For release branches, use the branch version with ea + echo "version=$(npm version ${BASH_REMATCH[1]}.0-ea.1 --no-git-tag-version)" >> "$GITHUB_OUTPUT" + else + # For main branch, just increment the ea version + echo "version=$(npm version prerelease --no-git-tag-version --preid ea)" >> "$GITHUB_OUTPUT" + fi - name: Install project modules run: npm ci From 7b077261af20e5b785018f64d6c283233948d5f9 Mon Sep 17 00:00:00 2001 From: Ruben Romero Montes Date: Thu, 22 May 2025 13:39:22 +0200 Subject: [PATCH 2/2] chore(ci): the ea id is taken from the package.json. no need to distinguish Signed-off-by: Ruben Romero Montes --- .github/workflows/stage.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/stage.yml b/.github/workflows/stage.yml index c62dad5..cbad2af 100644 --- a/.github/workflows/stage.yml +++ b/.github/workflows/stage.yml @@ -95,13 +95,7 @@ jobs: - name: Update package with new version id: bump run: | - if [[ "${{ github.base_ref }}" =~ ^release/([0-9]+\.[0-9]+)\.x$ ]]; then - # For release branches, use the branch version with ea - echo "version=$(npm version ${BASH_REMATCH[1]}.0-ea.1 --no-git-tag-version)" >> "$GITHUB_OUTPUT" - else - # For main branch, just increment the ea version - echo "version=$(npm version prerelease --no-git-tag-version --preid ea)" >> "$GITHUB_OUTPUT" - fi + echo "version=$(npm version prerelease --no-git-tag-version --preid ea)" >> "$GITHUB_OUTPUT" - name: Install project modules run: npm ci