Skip to content

Commit

Permalink
fix: setup release-please (#330)
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan authored Sep 13, 2023
1 parent 0029298 commit b20b109
Show file tree
Hide file tree
Showing 6 changed files with 5,405 additions and 12,234 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,10 @@
name: CI & Release

# Workflow name based on selected inputs. Fallback to default Github naming when expression evaluates to empty string
run-name: >-
${{
inputs.release && 'Publish to NPM' ||
''
}}
on:
merge_group:
pull_request:
push:
branches: [main]
workflow_dispatch:
inputs:
release:
description: 'Publish new release'
required: true
default: false
type: boolean

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down Expand Up @@ -187,33 +173,3 @@ jobs:
with:
name: build-output
- run: npm run test:node-runtimes

release:
permissions:
contents: write # to be able to publish a GitHub release
issues: write # to be able to comment on released issues
pull-requests: write # to be able to comment on released pull requests
id-token: write # to enable use of OIDC for npm provenance
needs: [build, test, deno-runtime, bun-runtime, edge-runtime, browser-runtime, node-runtimes]
# only run if opt-in during workflow_dispatch
if: github.event.inputs.release == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# Need to fetch entire commit history to
# analyze every commit since last release
fetch-depth: 0
- uses: actions/setup-node@v3
with:
node-version: lts/*
cache: npm
- run: npm ci
# Branches that will release new versions are defined in .releaserc.json
- run: npx semantic-release
# Don't allow interrupting the release step if the job is cancelled, as it can lead to an inconsistent state
# e.g. git tags were pushed but it exited before `npm publish`
if: always()
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
49 changes: 49 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
name: Release Please

on:
push:
branches:
- main

permissions:
contents: read

jobs:
release-please:
permissions:
id-token: write # to enable use of OIDC for npm provenance
# permissions for pushing commits and opening PRs are handled by the `generate-token` step
runs-on: ubuntu-latest
steps:
- uses: tibdex/github-app-token@0914d50df753bbc42180d982a6550f195390069f # v2
id: generate-token
with:
app_id: ${{ secrets.ECOSPARK_APP_ID }}
private_key: ${{ secrets.ECOSPARK_APP_PRIVATE_KEY }}
# This action will create a release PR when regular conventional commits are pushed to main, it'll also detect if a release PR is merged and npm publish should happen
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
token: ${{ steps.generate-token.outputs.token }}

# Publish to NPM on new releases
- uses: actions/checkout@v4
if: ${{ steps.release.outputs.releases_created }}
- uses: actions/setup-node@v3
if: ${{ steps.release.outputs.releases_created }}
with:
cache: npm
node-version: lts/*
registry-url: 'https://registry.npmjs.org'
- run: npm ci --ignore-scripts
if: ${{ steps.release.outputs.releases_created }}
- run: npm audit signatures
if: ${{ steps.release.outputs.releases_created }}
# Release Please has already incremented versions and published tags, so we just
# need to publish the new version to npm here
- run: npm publish --provenance
if: ${{ steps.release.outputs.releases_created }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
4 changes: 0 additions & 4 deletions .releaserc.json

This file was deleted.

7 changes: 0 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1165,13 +1165,6 @@ client.config({dataset: 'newDataset'})

Set client configuration. Required options are `projectId` and `dataset`.

## Release new version

Run ["CI & Release" workflow](https://github.com/sanity-io/client/actions/workflows/ci.yml).
Make sure to select the main branch and check "Release new version".

Semantic release will only release on configured branches, so it is safe to run release on any branch.

## License

MIT © [Sanity.io](https://www.sanity.io/)
Expand Down
Loading

0 comments on commit b20b109

Please sign in to comment.