Skip to content

ci: automate releases #376

ci: automate releases

ci: automate releases #376

Workflow file for this run

name: CI
on: [push]
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [22.23.2]
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version: ${{ matrix.node-version }}
- name: yarn, build, and test
run: |
yarn
yarn test
env:
CI: true
NODE_ENV: test
LINEAR_API_KEY: ${{ secrets.LINEAR_API_KEY }}
LINEAR_TEAM_ID: ${{ secrets.LINEAR_TEAM_ID }}
- name: Install the Zapier CLI
run: |
npm install --no-save --prefix "$RUNNER_TEMP/cli" zapier-platform-cli@19.1.0
echo "$RUNNER_TEMP/cli/node_modules/.bin" >> "$GITHUB_PATH"
- name: Validate the Zapier schema
run: |
yarn zapier-build
zapier-platform validate --without-style
version:
name: Version bump
if: github.ref_name != 'master'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
fetch-depth: 0
persist-credentials: false
- uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0
with:
node-version-file: .nvmrc
- name: Require a version bump for shipped changes
run: |
git fetch --no-tags origin master
base=$(git merge-base origin/master HEAD)
changed=$(git diff --name-only "$base..HEAD" -- src index.js tsconfig.json ':(exclude)src/test')
git show "$base:package.json" > "$RUNNER_TEMP/base-package.json"
deps=$(node scripts/dependencies-changed.js "$RUNNER_TEMP/base-package.json" package.json)
if [ -z "$changed" ] && [ "$deps" = "false" ]; then
echo "nothing here reaches Zapier, no version bump needed"
exit 0
fi
git show origin/master:package.json > "$RUNNER_TEMP/master-package.json"
master_version=$(node -p "JSON.parse(require('fs').readFileSync(process.env.RUNNER_TEMP + '/master-package.json', 'utf8')).version")
head_version=$(node -p "require('./package.json').version")
if [ "$master_version" = "$head_version" ]; then
echo "This branch changes code that reaches Zapier but leaves the version at $head_version." >&2
echo "Raise the minor version in package.json and add a matching '## <version>' entry to CHANGELOG.md." >&2
exit 1
fi
if [ "$(printf '%s\n%s\n' "$master_version" "$head_version" | sort -V | tail -1)" != "$head_version" ]; then
echo "Version $head_version is behind master, which is at $master_version. Rebase and bump again." >&2
exit 1
fi
if ! grep -q "^## ${head_version}\$" CHANGELOG.md; then
echo "CHANGELOG.md has no '## ${head_version}' entry, and Zapier reads that entry when the version is promoted." >&2
exit 1
fi
echo "version $master_version -> $head_version"