Skip to content

Commit

Permalink
feat: use new release flow (#2229)
Browse files Browse the repository at this point in the history
  • Loading branch information
saihaj authored Aug 11, 2022
1 parent 6892035 commit e7f19f2
Show file tree
Hide file tree
Showing 8 changed files with 191 additions and 389 deletions.
15 changes: 11 additions & 4 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": [
"@changesets/changelog-github",
{ "repo": "urigo/graphql-modules" }
],
"commit": false,
"linked": [],
"access": "restricted",
"access": "public",
"baseBranch": "master",
"updateInternalDependencies": "patch",
"ignore": [
Expand All @@ -12,5 +15,9 @@
"examples-di",
"examples-subscriptions",
"graphql-yoga"
]
],
"snapshot": {
"useCalculatedVersion": true,
"prereleaseTemplate": "{tag}-{datetime}-{commit}"
}
}
74 changes: 18 additions & 56 deletions .github/workflows/canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,72 +4,34 @@ on:
pull_request:
branches:
- master
paths:
- ".changeset/**/*.md"

jobs:
publish-canary:
name: Publish Canary
canary:
runs-on: ubuntu-latest
if: contains(github.actor, 'dependabot') == false
if: github.event.pull_request.head.repo.full_name == github.repository || github.event.inputs.onDemand == 'yes'
steps:
- name: Checkout Master
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Use Node
uses: actions/setup-node@v2
with:
node-version: 18
- name: Configure Git Credentials
run: |
git config --global user.email "[email protected]"
git config --global user.name "theguild-bot"
echo "machine github.com login theguild-bot password ${{secrets.GH_API_TOKEN}}" > ~/.netrc
- name: Setup NPM credentials
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- uses: actions/cache@v2
name: Cache node_modules
uses: actions/setup-node@v3
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-18-16-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-18-16
${{ runner.os }}-yarn-18-
${{ runner.os }}-yarn-
node-version: 16
cache: "yarn"

- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
run: yarn

- name: Release Canary
id: canary
uses: 'kamilkisiela/release-canary@master'
if: github.repository == 'urigo/graphql-modules'
with:
npm-token: ${{ secrets.NODE_AUTH_TOKEN }}
npm-script: 'yarn release:canary'
changesets: true
- name: Publish a message
if: steps.canary.outputs.released
uses: 'kamilkisiela/pr-comment@master'
uses: "the-guild-org/changesets-snapshot-action@main"
with:
message: |
The latest changes of this PR are available as alpha in npm (based on the declared `changesets`):
```
${{ steps.canary.outputs.changesetsPublishedPackages}}
```
bot-token: ${{ secrets.GH_API_TOKEN }}
bot: 'theguild-bot'
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Publish a empty message
if: steps.canary.outputs.released == 'false'
uses: 'kamilkisiela/pr-comment@master'
with:
message: |
The latest changes of this PR are not available as alpha, since there are no linked `changesets` for this PR.
$ yarn pr
Describe changes introduced in this Pull Request by running the above command.
bot-token: ${{ secrets.GH_API_TOKEN }}
bot: 'theguild-bot'
github-token: ${{ secrets.GITHUB_TOKEN }}
tag: alpha
prepareScript: "yarn build"
env:
NPM_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
18 changes: 18 additions & 0 deletions .github/workflows/dependencies.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: Dependencies Changeset

on: pull_request

jobs:
changeset:
if: github.event.pull_request.head.repo.full_name == github.repository
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Create/Update Changesets
uses: "the-guild-org/changesets-dependencies-action@main"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62 changes: 28 additions & 34 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,48 @@
name: Release

on:
push:
branches:
- master

jobs:
build:
release:
name: stable
runs-on: ubuntu-latest
steps:
- name: Checkout Master
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Configure Git Credentials
run: |
git config --global user.email "[email protected]"
git config --global user.name "theguild-bot"
echo "machine github.com login theguild-bot password ${{secrets.GH_API_TOKEN}}" > ~/.netrc
- name: Add origin remote and refetch master
run: |
git remote rm origin
git remote add origin "https://github.com/${{github.repository}}"
git fetch
git checkout master
git reset --hard

- name: Use Node
uses: actions/setup-node@v2
uses: actions/setup-node@v3
with:
node-version: 18
- name: Setup NPM credentials
run: echo "//registry.npmjs.org/:_authToken=$NODE_AUTH_TOKEN" >> ~/.npmrc
env:
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
- uses: actions/cache@v2
name: Cache node_modules
with:
path: '**/node_modules'
key: ${{ runner.os }}-yarn-18-16-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-18-16-
${{ runner.os }}-yarn-18-
${{ runner.os }}-yarn-
node-version: 16
cache: "yarn"

- name: Install Dependencies using Yarn
run: yarn install --ignore-engines && git checkout yarn.lock
run: yarn

- name: Build Packages
run: yarn build

- name: set version variables
id: vars
shell: bash
run: |
echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@master
uses: dotansimha/changesets-action@v1.3.1
with:
publish: yarn release
commit: 'chore(release): update monorepo packages versions'
title: 'Upcoming Release Changes'
commit: "chore(release): update monorepo packages versions"
title: "Upcoming Release Changes"
createGithubReleases: aggregate
githubReleaseName: "Release ${{ steps.vars.outputs.sha_short }} (from ${{ steps.vars.outputs.branch }})"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"test": "jest",
"prerelease": "yarn build",
"release": "changeset publish",
"release:canary": "(node scripts/canary-release.js && yarn build && yarn changeset publish --tag alpha) || echo Skipping Canary...",
"format": "prettier --ignore-path .gitignore --write \"packages/**/*.{js,jsx,json,css,md,mdx,ts,tsx}\"",
"pr": "changeset",
"lint": "eslint \"packages/**/*.{js,jsx,ts,tsx}\"",
Expand All @@ -30,8 +29,8 @@
"@babel/preset-typescript": "7.17.12",
"@babel/plugin-proposal-decorators": "7.18.2",
"@babel/plugin-proposal-class-properties": "7.17.12",
"@changesets/apply-release-plan": "5.0.1",
"@changesets/cli": "2.23.0",
"@changesets/cli": "2.24.2",
"@changesets/changelog-github": "0.4.6",
"@envelop/graphql-modules": "3.3.3",
"@graphql-tools/merge": "8.2.14",
"@graphql-yoga/node": "2.9.2",
Expand Down
79 changes: 0 additions & 79 deletions patches/@changesets+apply-release-plan+5.0.1.patch

This file was deleted.

Loading

1 comment on commit e7f19f2

@vercel
Copy link

@vercel vercel bot commented on e7f19f2 Aug 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.