Skip to content

Release

Release #132

Workflow file for this run

name: Release
run-name: >-
${{ github.event.inputs.dry-run == 'true' && 'Release dry-run' || 'Release' }}
on:
workflow_dispatch:
inputs:
version:
type: choice
description: The new version to build and publish
required: true
default: 'patch'
options:
- major
- minor
- patch
dry-run:
type: boolean
description: Perform a dry run
required: true
default: true
jobs:
npm:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node.js for NPM
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
registry-url: 'https://registry.npmjs.org'
scope: '@customerio'
- name: Install npm 11.5.1+ for OIDC support
run: npm install -g npm@11
- name: Install
run: |
yarn install --frozen-lockfile
- name: Bump core
run: |
cd packages/core
yarn version ${{ github.event.inputs.version }}
- name: Bump browser
run: |
cd packages/browser
yarn version ${{ github.event.inputs.version }}
yarn run build-prep
- name: Bump node
run: |
cd packages/node
yarn version ${{ github.event.inputs.version }}
- name: Build
run: |
yarn build
- name: Publish (dry-run)
if: ${{ github.event.inputs.dry-run == 'true' }}
run: |
for package in core browser node; do
pushd packages/$package
npm publish --dry-run --access public
popd
done
- name: Publish
if: ${{ github.event.inputs.dry-run == 'false' }}
run: |
for package in core browser node; do
pushd packages/$package
npm publish --access public
popd
done
github:
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
packages: write
contents: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup node.js for GitHub
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'yarn'
registry-url: 'https://npm.pkg.github.com'
scope: '@customerio'
- name: Install npm 11.5.1+ for OIDC support
run: npm install -g npm@11
- name: Install
run: |
yarn install --frozen-lockfile
- name: Bump core
run: |
cd packages/core
yarn version ${{ github.event.inputs.version }}
- name: Bump browser
run: |
cd packages/browser
yarn version ${{ github.event.inputs.version }}
yarn run build-prep
- name: Bump node
run: |
cd packages/node
yarn version ${{ github.event.inputs.version }}
- name: Build
run: |
yarn build
- name: Publish (dry-run)
if: ${{ github.event.inputs.dry-run == 'true' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for package in core browser node; do
pushd packages/$package
npm publish --dry-run
popd
done
- name: Publish
if: ${{ github.event.inputs.dry-run == 'false' }}
env:
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
for package in core browser node; do
pushd packages/$package
npm publish
popd
done
commit:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
needs: [npm, github]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set Git Identity
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Install
run: |
yarn install --frozen-lockfile
- name: Bump core
run: |
cd packages/core
yarn version ${{ github.event.inputs.version }}
- name: Bump browser
run: |
cd packages/browser
yarn version ${{ github.event.inputs.version }}
yarn run build-prep
- name: Bump node
run: |
cd packages/node
yarn version ${{ github.event.inputs.version }}
- name: Show commit (dry-run)
if: ${{ github.event.inputs.dry-run == 'true' }}
run: |
git commit -am "Update version"
git show
- name: Open and merge version bump PR
if: ${{ github.event.inputs.dry-run == 'false' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
branch="release/version-bump-${{ github.run_id }}"
git checkout -b "$branch"
git commit -am "Update version"
git push origin "$branch"
pr_url=$(gh pr create \
--base "${{ github.ref_name }}" \
--head "$branch" \
--title "Update version" \
--body "Version bump from [release run ${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).")
echo "Opened $pr_url"
merge_once_github_finishes_computing_mergeability() {
for attempt in $(seq 6); do
gh pr merge "$branch" --squash && return 0
echo "Not mergeable yet (attempt $attempt), waiting 10s"
sleep 10
done
return 1
}
if merge_once_github_finishes_computing_mergeability; then
echo "Merged $pr_url"
else
echo "::error::Could not merge the version bump PR. Merge it manually: $pr_url"
exit 1
fi