Skip to content

Commit

Permalink
chore(ci): move to release-please
Browse files Browse the repository at this point in the history
  • Loading branch information
stipsan committed Sep 29, 2023
1 parent c04ac20 commit 751c07c
Show file tree
Hide file tree
Showing 5 changed files with 769 additions and 2,056 deletions.
31 changes: 1 addition & 30 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
name: CI

on:
merge_group:
push:
branches:
- alpha
- beta
- main
pull_request:
branches:
- alpha
- beta
- main

concurrency:
Expand Down Expand Up @@ -53,29 +50,3 @@ jobs:
- run: corepack enable && pnpm --version
- run: pnpm install
- run: pnpm test

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
name: 'Semantic release'
needs: [build, test]
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/*
- run: corepack enable && pnpm --version
- run: pnpm install
# Branches that will release new versions are defined in "release" in "package.json"
- run: pnpm exec semantic-release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
2 changes: 1 addition & 1 deletion .github/workflows/format-if-needed.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
- run: corepack enable && pnpm --version
- run: pnpm install --ignore-scripts
- run: pnpm format
- run: git restore .github/workflows
- run: git restore .github/workflows CHANGELOG.md
- uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2
id: generate-token
with:
Expand Down
54 changes: 54 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
---
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@3beb63f4bd073e61482598c45c71c1019b59b73a # v2
id: generate-token
with:
app_id: ${{ secrets.ECOSCRIPT_APP_ID }}
private_key: ${{ secrets.ECOSCRIPT_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: pnpm/action-setup@v2
if: ${{ steps.release.outputs.releases_created }}
- uses: actions/setup-node@v3
if: ${{ steps.release.outputs.releases_created }}
with:
cache: pnpm
node-version: lts/*
registry-url: 'https://registry.npmjs.org'
- run: corepack enable && pnpm --version && pnpm install
if: ${{ steps.release.outputs.releases_created }}
- name: Set publishing config
run: pnpm config set '//registry.npmjs.org/:_authToken' "${NODE_AUTH_TOKEN}"
if: ${{ steps.release.outputs.releases_created }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_PUBLISH_TOKEN}}
# Release Please has already incremented versions and published tags, so we just
# need to publish the new version to npm here
- run: pnpm publish
if: ${{ steps.release.outputs.releases_created }}
env:
NPM_CONFIG_PROVENANCE: true
11 changes: 1 addition & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,12 @@
"lib/**/"
]
},
"release": {
"branches": [
"main"
],
"extends": "@sanity/semantic-release-preset"
},
"dependencies": {
"@portabletext/react": "^3.0.7",
"@portabletext/types": "^2.0.6"
},
"devDependencies": {
"@react-native/polyfills": "^2.0.0",
"@sanity/semantic-release-preset": "^4.1.4",
"@types/react": "^18.2.23",
"@types/react-native": "^0.72.3",
"@types/react-test-renderer": "^18.0.3",
Expand All @@ -84,7 +77,6 @@
"react": "^18.2.0",
"react-native": "^0.72.5",
"react-test-renderer": "^18.2.0",
"semantic-release": "^21.1.1",
"typescript": "^5.2.2",
"vite": "^4.4.9",
"vite-plugin-dts": "^3.6.0",
Expand All @@ -97,7 +89,6 @@
},
"packageManager": "pnpm@8.8.0",
"publishConfig": {
"access": "public",
"provenance": true
"access": "public"
}
}
Loading

0 comments on commit 751c07c

Please sign in to comment.