From 8d2b09acd9876f3eb5e2f09eccc78edfaf297a99 Mon Sep 17 00:00:00 2001 From: Yevhen Kyriukha Date: Wed, 4 Feb 2026 05:23:32 +0200 Subject: [PATCH 1/3] feat: support GitHub prereleases for snapshot tags - Handle tag-based releases in export_version_from_package - Skip branch checkout when running from tag - Skip SBOM generation for tag-based releases - Add --prerelease flag for snapshot/hotfix/perf versions - Add GitHub prerelease workflow job triggered on snapshot tags --- src/commands/export_version_from_package.yml | 7 ++++++- src/jobs/github_release.yml | 17 +++++++++++++++-- src/workflows/build_and_test.yml | 12 ++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) diff --git a/src/commands/export_version_from_package.yml b/src/commands/export_version_from_package.yml index 1e066f2..b1d9088 100644 --- a/src/commands/export_version_from_package.yml +++ b/src/commands/export_version_from_package.yml @@ -4,6 +4,11 @@ steps: - run: name: Format the changelog into the github release body and get release tag command: | - git diff --no-indent-heuristic ${CIRCLE_BRANCH}~1 HEAD CHANGELOG.md | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes + if [ -n "$CIRCLE_TAG" ]; then + echo "Running from tag, using tag commit for changelog diff" + git diff --no-indent-heuristic HEAD~1 HEAD CHANGELOG.md 2>/dev/null | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes || echo "Prerelease" > /tmp/changes + else + git diff --no-indent-heuristic ${CIRCLE_BRANCH}~1 HEAD CHANGELOG.md | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes + fi echo 'export RELEASE_CHANGES=`cat /tmp/changes`' >> $BASH_ENV echo 'export RELEASE_TAG=`cat package.json | jq -r .version`' >> $BASH_ENV diff --git a/src/jobs/github_release.yml b/src/jobs/github_release.yml index 810799b..e7cb7e5 100755 --- a/src/jobs/github_release.yml +++ b/src/jobs/github_release.yml @@ -26,7 +26,11 @@ steps: name: Fetch updated release branch command: | git fetch origin - git checkout origin/${CIRCLE_BRANCH} + if [ -n "$CIRCLE_TAG" ]; then + echo "Running from tag $CIRCLE_TAG, skipping branch checkout" + else + git checkout origin/${CIRCLE_BRANCH} + fi - export_version_from_package - run: name: Check the release changes @@ -44,6 +48,10 @@ steps: - run: name: Generate SBOM command: | + if [ -n "$CIRCLE_TAG" ]; then + echo "Running from tag, skipping SBOM generation" + exit 0 + fi if ls | grep -Eq '^sbom-v[0-9]+\.[0-9]+\.[0-9]+\.csv$'; then git fetch origin "$CIRCLE_BRANCH" git checkout -B "$CIRCLE_BRANCH" "origin/$CIRCLE_BRANCH" @@ -67,7 +75,12 @@ steps: - run: name: Create Release command: | - gh release create "v${RELEASE_TAG}" --repo ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} --title "v${RELEASE_TAG} Release" --draft=false --notes "${RELEASE_CHANGES}" ./CHANGELOG.md + PRERELEASE_FLAG="" + if [[ "$RELEASE_TAG" =~ -(snapshot|hotfix|perf)\.[0-9]+$ ]]; then + PRERELEASE_FLAG="--prerelease" + echo "Creating prerelease for $RELEASE_TAG" + fi + gh release create "v${RELEASE_TAG}" $PRERELEASE_FLAG --repo ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} --title "v${RELEASE_TAG} Release" --draft=false --notes "${RELEASE_CHANGES}" ./CHANGELOG.md - when: condition: << parameters.slack >> steps: diff --git a/src/workflows/build_and_test.yml b/src/workflows/build_and_test.yml index 72076d4..0f700e6 100644 --- a/src/workflows/build_and_test.yml +++ b/src/workflows/build_and_test.yml @@ -275,6 +275,18 @@ workflows: resource_class: << pipeline.parameters.publish_npm_snapshot_resource_class >> yarn_lock: << pipeline.parameters.yarn_lock >> slack: << pipeline.parameters.slack >> + - build/github_release: + name: GitHub prerelease + resource_class: << pipeline.parameters.github_release_resource_class >> + slack: << pipeline.parameters.slack >> + context: org-global + filters: + branches: + ignore: + - /.*/ + tags: + only: /v\d+(\.\d+){2}-(snapshot|hotfix|perf)\.\d+/ + requires: *tests - build/publish_npm_prerelease: name: NPM prerelease resource_class: << pipeline.parameters.publish_npm_prerelease_resource_class >> From 27d817a86b0d89a7dbe858138a99ba6558e153df Mon Sep 17 00:00:00 2001 From: Yevhen Kyriukha Date: Fri, 5 Jun 2026 17:56:02 +0300 Subject: [PATCH 2/3] refactor: move prerelease handling into dedicated github_prerelease job --- README.md | 1 + src/commands/export_version_from_package.yml | 7 +-- src/jobs/github_prerelease.yml | 57 ++++++++++++++++++++ src/jobs/github_release.yml | 17 +----- src/jobs/workflow.yml | 5 ++ src/workflows/build_and_test.yml | 9 ++-- 6 files changed, 72 insertions(+), 24 deletions(-) create mode 100644 src/jobs/github_prerelease.yml diff --git a/README.md b/README.md index 6f80972..9528bdb 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ workflows: # grype_scan_resource_class: medium # release_resource_class: medium # github_release_resource_class: medium + # github_prerelease_resource_class: medium # publish_docker_resource_class: medium # publish_npm_resource_class: medium # publish_docker_snapshot_resource_class: medium diff --git a/src/commands/export_version_from_package.yml b/src/commands/export_version_from_package.yml index b1d9088..1e066f2 100644 --- a/src/commands/export_version_from_package.yml +++ b/src/commands/export_version_from_package.yml @@ -4,11 +4,6 @@ steps: - run: name: Format the changelog into the github release body and get release tag command: | - if [ -n "$CIRCLE_TAG" ]; then - echo "Running from tag, using tag commit for changelog diff" - git diff --no-indent-heuristic HEAD~1 HEAD CHANGELOG.md 2>/dev/null | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes || echo "Prerelease" > /tmp/changes - else - git diff --no-indent-heuristic ${CIRCLE_BRANCH}~1 HEAD CHANGELOG.md | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes - fi + git diff --no-indent-heuristic ${CIRCLE_BRANCH}~1 HEAD CHANGELOG.md | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes echo 'export RELEASE_CHANGES=`cat /tmp/changes`' >> $BASH_ENV echo 'export RELEASE_TAG=`cat package.json | jq -r .version`' >> $BASH_ENV diff --git a/src/jobs/github_prerelease.yml b/src/jobs/github_prerelease.yml new file mode 100644 index 0000000..3262dab --- /dev/null +++ b/src/jobs/github_prerelease.yml @@ -0,0 +1,57 @@ +description: | + This job creates a Github pre-release for the project when a prerelease tag + (e.g. v1.2.3-snapshot.1, v1.2.3-hotfix.1, v1.2.3-perf.1) is pushed. +executor: + name: machine + resource_class: << parameters.resource_class >> +shell: "/bin/bash -eo pipefail" +environment: + MAIN_BRANCH_NAME: main +parameters: + resource_class: + type: enum + enum: ["small", "medium", "medium+", "large", "xlarge", "2xlarge", "2xlarge+"] + default: medium +steps: + - run: + name: Install git + command: | + sudo apt-get update && sudo apt-get install -y git + - gh/install + - checkout + - attach_workspace: + at: /tmp + - run: + name: Format the changelog into the github release body and get release tag + command: | + git diff --no-indent-heuristic HEAD~1 HEAD CHANGELOG.md 2>/dev/null | sed -n '/^+[^+]/ s/^+//p' > /tmp/changes || true + # changelog updates are skipped for snapshots, so the diff is usually empty + if [ ! -s /tmp/changes ]; then + echo "Prerelease" > /tmp/changes + fi + echo 'export RELEASE_CHANGES=`cat /tmp/changes`' >> $BASH_ENV + echo 'export RELEASE_TAG=`cat package.json | jq -r .version`' >> $BASH_ENV + - run: + name: Check the release changes + command: | + echo "Changes are: ${RELEASE_CHANGES}" + - run: + name: Create Pre-release + command: | + gh release create "v${RELEASE_TAG}" --prerelease --repo ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} --title "v${RELEASE_TAG} Release" --draft=false --notes "${RELEASE_CHANGES}" ./CHANGELOG.md + - run: + name: Upload Release Assets + command: | + RELEASE_ASSETS_DIR="/tmp/release-assets" + if [ -d "$RELEASE_ASSETS_DIR" ] && [ "$(ls -A $RELEASE_ASSETS_DIR 2>/dev/null)" ]; then + echo "Found release assets in workspace:" + ls -la "$RELEASE_ASSETS_DIR" + for asset in "$RELEASE_ASSETS_DIR"/*; do + if [ -f "$asset" ]; then + echo "Uploading: $(basename "$asset")" + gh release upload "v${RELEASE_TAG}" "$asset" --repo ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} + fi + done + else + echo "No release assets found in workspace, skipping..." + fi diff --git a/src/jobs/github_release.yml b/src/jobs/github_release.yml index 6d3d793..ab3edd3 100755 --- a/src/jobs/github_release.yml +++ b/src/jobs/github_release.yml @@ -28,11 +28,7 @@ steps: name: Fetch updated release branch command: | git fetch origin - if [ -n "$CIRCLE_TAG" ]; then - echo "Running from tag $CIRCLE_TAG, skipping branch checkout" - else - git checkout origin/${CIRCLE_BRANCH} - fi + git checkout origin/${CIRCLE_BRANCH} - export_version_from_package - run: name: Check the release changes @@ -50,10 +46,6 @@ steps: - run: name: Generate SBOM command: | - if [ -n "$CIRCLE_TAG" ]; then - echo "Running from tag, skipping SBOM generation" - exit 0 - fi if ls | grep -Eq '^sbom-v[0-9]+\.[0-9]+\.[0-9]+\.csv$'; then git fetch origin "$CIRCLE_BRANCH" git checkout -B "$CIRCLE_BRANCH" "origin/$CIRCLE_BRANCH" @@ -77,12 +69,7 @@ steps: - run: name: Create Release command: | - PRERELEASE_FLAG="" - if [[ "$RELEASE_TAG" =~ -(snapshot|hotfix|perf)\.[0-9]+$ ]]; then - PRERELEASE_FLAG="--prerelease" - echo "Creating prerelease for $RELEASE_TAG" - fi - gh release create "v${RELEASE_TAG}" $PRERELEASE_FLAG --repo ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} --title "v${RELEASE_TAG} Release" --draft=false --notes "${RELEASE_CHANGES}" ./CHANGELOG.md + gh release create "v${RELEASE_TAG}" --repo ${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME} --title "v${RELEASE_TAG} Release" --draft=false --notes "${RELEASE_CHANGES}" ./CHANGELOG.md - run: name: Upload Release Assets command: | diff --git a/src/jobs/workflow.yml b/src/jobs/workflow.yml index 9a87392..56bc3e6 100644 --- a/src/jobs/workflow.yml +++ b/src/jobs/workflow.yml @@ -65,6 +65,10 @@ parameters: type: enum enum: ["small", "medium", "medium+", "large", "xlarge", "2xlarge", "2xlarge+"] default: medium + github_prerelease_resource_class: + type: enum + enum: ["small", "medium", "medium+", "large", "xlarge", "2xlarge", "2xlarge+"] + default: medium publish_docker_resource_class: type: enum enum: ["small", "medium", "medium+", "large", "xlarge", "2xlarge", "2xlarge+"] @@ -115,6 +119,7 @@ steps: "grype_scan_resource_class":"<< parameters.grype_scan_resource_class>>", "release_resource_class":"<< parameters.release_resource_class>>", "github_release_resource_class":"<< parameters.github_release_resource_class>>", + "github_prerelease_resource_class":"<< parameters.github_prerelease_resource_class>>", "publish_docker_resource_class":"<< parameters.publish_docker_resource_class>>", "publish_npm_resource_class":"<< parameters.publish_npm_resource_class>>", "publish_docker_snapshot_resource_class":"<< parameters.publish_docker_snapshot_resource_class>>", diff --git a/src/workflows/build_and_test.yml b/src/workflows/build_and_test.yml index f3483b7..e9db2eb 100644 --- a/src/workflows/build_and_test.yml +++ b/src/workflows/build_and_test.yml @@ -81,6 +81,10 @@ parameters: type: enum enum: ["small", "medium", "medium+", "large", "xlarge", "2xlarge", "2xlarge+"] default: medium + github_prerelease_resource_class: + type: enum + enum: ["small", "medium", "medium+", "large", "xlarge", "2xlarge", "2xlarge+"] + default: medium publish_docker_resource_class: type: enum enum: ["small", "medium", "medium+", "large", "xlarge", "2xlarge", "2xlarge+"] @@ -276,10 +280,9 @@ workflows: resource_class: << pipeline.parameters.publish_npm_snapshot_resource_class >> yarn_lock: << pipeline.parameters.yarn_lock >> slack: << pipeline.parameters.slack >> - - build/github_release: + - build/github_prerelease: name: GitHub prerelease - resource_class: << pipeline.parameters.github_release_resource_class >> - slack: << pipeline.parameters.slack >> + resource_class: << pipeline.parameters.github_prerelease_resource_class >> context: org-global filters: branches: From c8969ed5c6a515a6a93ced6ba36d8a85a1e48214 Mon Sep 17 00:00:00 2001 From: Yevhen Kyriukha Date: Fri, 5 Jun 2026 17:58:26 +0300 Subject: [PATCH 3/3] chore: bump orb version refs to 1.1.20 --- README.md | 2 +- src/examples/build_and_test.yml | 2 +- src/workflows/build_and_test.yml | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9528bdb..28056a6 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ project settings CircleCI. Then include the following in your `.circleci/config. version: 2.1 setup: true orbs: - build: mojaloop/build@1.1.17 + build: mojaloop/build@1.1.20 workflows: setup: jobs: diff --git a/src/examples/build_and_test.yml b/src/examples/build_and_test.yml index 5148887..ca5bf09 100644 --- a/src/examples/build_and_test.yml +++ b/src/examples/build_and_test.yml @@ -4,7 +4,7 @@ usage: version: 2.1 setup: true orbs: - build: mojaloop/build@1.1.17 + build: mojaloop/build@1.1.20 workflows: setup: jobs: diff --git a/src/workflows/build_and_test.yml b/src/workflows/build_and_test.yml index e9db2eb..e1f2146 100644 --- a/src/workflows/build_and_test.yml +++ b/src/workflows/build_and_test.yml @@ -1,6 +1,6 @@ version: 2.1 orbs: - build: mojaloop/build@1.1.17 + build: mojaloop/build@1.1.20 parameters: git_tag: type: string