-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduce changesets * Add check-prerelease workflow * Add repository check to prevent PR creation on forks
- Loading branch information
Showing
10 changed files
with
4,497 additions
and
180 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Changesets | ||
|
||
Hello and welcome! This folder has been automatically generated by `@changesets/cli`, a build tool that works | ||
with multi-package repos, or single-package repos to help you version and publish your code. You can | ||
find the full documentation for it [in our repository](https://github.com/changesets/changesets) | ||
|
||
We have a quick list of common questions to get you started engaging with this project in | ||
[our documentation](https://github.com/changesets/changesets/blob/main/docs/common-questions.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json", | ||
"changelog": [ | ||
"@changesets/changelog-github", | ||
{ "repo": "apollographql/apollo-client" } | ||
], | ||
"commit": false, | ||
"fixed": [], | ||
"linked": [], | ||
"access": "public", | ||
"baseBranch": "main", | ||
"updateInternalDependencies": "patch", | ||
"ignore": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
name: No prerelease file (pre.json) present | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
check_prerelease: | ||
name: "Check branch does not have a prerelease file committed" | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: "Check that the file .changeset/pre.json is not present" | ||
run: "! test -f .changeset/pre.json" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Exit Prerelease Mode | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
branch: | ||
description: "Exit prerelease mode on release branch" | ||
type: string | ||
default: "release-" | ||
required: true | ||
|
||
jobs: | ||
exit_prerelease: | ||
name: Changesets Exit Prerelease | ||
runs-on: ubuntu-latest | ||
# Allow GITHUB_TOKEN to have write permissions | ||
permissions: | ||
contents: write | ||
|
||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
with: | ||
# Checkout release branch entered when workflow was kicked off | ||
ref: ${{ github.event.inputs.branch }} | ||
# Fetch entire git history so Changesets can generate changelogs | ||
# with the correct commits | ||
fetch-depth: 0 | ||
|
||
- name: Setup Node.js 18.x | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 18.x | ||
|
||
- name: Get latest tagged version | ||
id: previoustag | ||
uses: WyriHaximus/github-action-get-previous-tag@v1 | ||
|
||
- name: Remove 'v' prefix from version number (e.g. v1.0.0) | ||
uses: mad9000/actions-find-and-replace-string@1 | ||
id: formatversion | ||
with: | ||
source: ${{ steps.previoustag.outputs.tag }} | ||
find: "v" | ||
replace: "" | ||
|
||
- name: Write previous version to package.json | ||
uses: jaywcjlove/[email protected] | ||
with: | ||
version: ${{ steps.formatversion.outputs.value }} | ||
|
||
- name: Remove pre.json | ||
run: npx rimraf .changeset/pre.json | ||
|
||
- uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Exit prerelease mode | ||
# Commit these changes to the branch workflow is running against | ||
branch: ${{ github.event.inputs.branch }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
name: Prerelease | ||
|
||
on: | ||
push: | ||
branches: | ||
# Target release-x.x branches | ||
- "release-*" | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
prerelease: | ||
name: Changesets Prerelease | ||
# Prevents changesets action from creating a PR on forks | ||
if: github.repository == 'apollographql/apollo-client' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
with: | ||
# Fetch entire git history so Changesets can generate changelogs | ||
# with the correct commits | ||
fetch-depth: 0 | ||
|
||
- name: Append NPM token to .npmrc | ||
run: | | ||
cat << EOF > "$HOME/.npmrc" | ||
//registry.npmjs.org/:_authToken=$NPM_TOKEN | ||
EOF | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Setup Node.js 18.x | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 18.x | ||
|
||
- name: Install dependencies with cache | ||
uses: bahmutov/npm-install@v1 | ||
|
||
- name: Enter prerelease mode | ||
# if .changeset/pre.json does not exist and we did not recently exit | ||
# prerelease mode, enter prerelease mode with tag alpha | ||
run: | | ||
[ ! -f .changeset/pre.json && !contains(github.event.head_commit.message, 'Exit prerelease') ] \ | ||
&& npx changeset pre enter alpha \ | ||
|| echo 'Already in pre mode or recently exited' | ||
- name: Create release PR | ||
id: changesets | ||
uses: changesets/action@v1 | ||
with: | ||
version: npm run changeset-version | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Publish alpha to npm | ||
if: "! test -f .changeset/pre.json" | ||
run: npm run changeset-publish | ||
|
||
# - name: Send a Slack notification on Publish | ||
# if: steps.changesets.outputs.published == 'true' | ||
# run: echo "Send message to Slack" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
concurrency: ${{ github.workflow }}-${{ github.ref }} | ||
|
||
jobs: | ||
release: | ||
name: Changesets Release | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v3 | ||
with: | ||
# Fetch entire git history so Changesets can generate changelogs | ||
# with the correct commits | ||
fetch-depth: 0 | ||
|
||
- name: Append NPM token to .npmrc | ||
run: | | ||
cat << EOF > "$HOME/.npmrc" | ||
//registry.npmjs.org/:_authToken=$NPM_TOKEN | ||
EOF | ||
env: | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
- name: Setup Node.js 18.x | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 18.x | ||
|
||
- name: Install dependencies (with cache) | ||
uses: bahmutov/npm-install@v1 | ||
|
||
- name: Create release PR or publish to npm + GitHub | ||
id: changesets | ||
uses: changesets/action@v1 | ||
with: | ||
version: npm run changeset-version | ||
publish: npm run changeset-publish | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
|
||
# - name: Send a Slack notification on Publish | ||
# if: steps.changesets.outputs.published == 'true' | ||
# run: echo "Send message to Slack" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.