Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/action/build/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Build
description: Reusable action to install dependencies, build the project, and run tests.

inputs:
node-version:
description: Node.js version to use
required: false
default: '20'

runs:
using: composite
steps:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: ${{ inputs.node-version }}
registry-url: 'https://npm.pkg.github.com/celonis'
scope: '@celonis'

- name: Install Dependencies
shell: bash
run: yarn install --frozen-lockfile

- name: Build
shell: bash
run: yarn build

- name: Test
shell: bash
run: yarn test
24 changes: 20 additions & 4 deletions .github/action/bump-npm-version/action.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
name: Bump NPM Version


inputs:
bump:
description: 'Which version bump (patch, minor, major)'
Expand All @@ -12,11 +11,18 @@ inputs:
description: 'GitHub repository to push changes to'
required: true

outputs:
auto_branch:
description: 'The created automation branch name'
value: ${{ steps.names.outputs.auto_branch }}

runs:
using: composite
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node.js
uses: actions/setup-node@v4
Expand All @@ -30,10 +36,20 @@ runs:
git config user.email 'github-celobot@celonis.com'
git remote set-url origin https://x-access-token:${{ inputs.token }}@github.com/${{ inputs.repository }}

- name: Run npm version
- name: Compute automation branch name
id: names
shell: bash
run: |
ts=$(date +"%Y%m%d-%H%M%S")
auto_branch="automation/release-bump-${ts}"
echo "auto_branch=${auto_branch}" >> $GITHUB_OUTPUT
echo "Creating automation branch: ${auto_branch}"
git checkout -b "${auto_branch}"

- name: Run npm version bump
shell: bash
run: |
npm version ${{ inputs.bump }} -m "chore: bump version to %s"
npm version ${{ inputs.bump }} -m "[Release] Bump version to %s"
npm install
git push origin HEAD
git push origin --tags
git push origin --tags
58 changes: 0 additions & 58 deletions .github/workflows/build-and-publish-automatic.yml

This file was deleted.

79 changes: 0 additions & 79 deletions .github/workflows/build-and-publish.yml

This file was deleted.

139 changes: 139 additions & 0 deletions .github/workflows/build-or-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
name: Build / Publish Workflow

on:
push:
branches:
- 'master'
Comment thread
promeris marked this conversation as resolved.
- 'release/*'
paths-ignore:
- '.github/**'

permissions:
contents: write

jobs:
detect-bump:
name: Detect Version Bump
runs-on: ubuntu-latest
outputs:
is_bump: ${{ steps.check.outputs.is_bump }}
commit_sha: ${{ steps.sha.outputs.sha }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2

- id: sha
run: echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT

- id: check
run: |
last_commit_message=$(git log -1 --pretty=%B)
echo "Last commit message: $last_commit_message"
if [[ "$last_commit_message" =~ "\[Release\] Bump version" ]]; then
echo "is_bump=true" >> $GITHUB_OUTPUT
else
echo "is_bump=false" >> $GITHUB_OUTPUT
fi

build-only:
name: Build (no publish)
runs-on: ubuntu-latest
needs: detect-bump
if: needs.detect-bump.outputs.is_bump != 'true'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Build and Test
uses: ./.github/action/build

- name: Done
run: echo "Regular commit detected — build and test completed."

create-release-branch-and-publish:
name: Create release branch (CalVer) and Publish
runs-on: ubuntu-latest
needs: detect-bump
if: needs.detect-bump.outputs.is_bump == 'true' && github.ref == 'refs/heads/master'
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Git user
run: |
git config user.name "celobot"
git config user.email "github-celobot@celonis.com"

- name: Compute unique CalVer release branch name
id: calver
run: |
base_name=$(date +"%Y%m%d-%H%M%S")

git fetch origin "+refs/heads/release/*:refs/remotes/origin/release/*" || true

rc_index=0
candidate="${base_name}_RC$(printf '%02d' $rc_index)"
while git branch -r | grep -q "origin/release/${candidate}"; do
rc_index=$((rc_index + 1))
candidate="${base_name}_RC$(printf '%02d' $rc_index)"
done
release_branch="release/${candidate}"
echo "release_branch=${release_branch}" >> $GITHUB_OUTPUT
echo "Selected release branch: ${release_branch}"

- name: Create and push release branch from current master commit
env:
GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
branch="${{ steps.calver.outputs.release_branch }}"
git checkout -b "$branch"
git push https://x-access-token:${GIT_TOKEN}@github.com/${{ github.repository }} "HEAD:refs/heads/${branch}"

- name: Build and Test
uses: ./.github/action/build

- name: Prepare dist
run: |
cp README.md dist/README.md
cp LICENSE dist/LICENSE

- name: Publish to GitHub Registry
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
cd dist/
npm publish

- name: Setup Node for NPM Registry
uses: actions/setup-node@v4
with:
node-version: '20'
registry-url: https://registry.npmjs.org/
scope: '@celonis'

- name: Publish to NPM Registry
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
cd dist/
npm publish --access public

- name: Tag release version
env:
GIT_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
version=$(node -p "require('./package.json').version")
tag="v${version}"
git tag "${tag}"
git push https://x-access-token:${GIT_TOKEN}@github.com/${{ github.repository }} "${tag}"

- name: Post-publish note
run: echo "Release branch ${{ steps.calver.outputs.release_branch }} created, published, and tagged with version."
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Build Workflow
name: Build Pull Request

on:
pull_request:
Expand Down
Loading