Skip to content

Commit

Permalink
Add snapshot release workflow (#7999)
Browse files Browse the repository at this point in the history
Co-authored-by: Mitchell Hamilton <mitchell@hamil.town>
Co-authored-by: Daniel Cousens <dcousens@users.noreply.github.com>
  • Loading branch information
emmatown and dcousens committed Oct 13, 2022
1 parent 075c500 commit aef70b8
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 59 deletions.
3 changes: 2 additions & 1 deletion .github/actions/ci-setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ runs:
with:
# preferably lts/*, but we hit API limits when querying that
node-version: 16
registry-url: 'https://registry.npmjs.org'

- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
shell: bash

- uses: actions/cache@v3
- uses: actions/cache@main
id: yarn-cache
with:
path: |
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/always_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@ jobs:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Prettier
Expand All @@ -40,9 +38,7 @@ jobs:
name: Package Unit Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Unit tests
Expand Down
36 changes: 10 additions & 26 deletions .github/workflows/core_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ jobs:
matrix:
index: [1, 2, 3, 4, 5, 6, 7, 8, 9]
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Unit tests
Expand All @@ -51,9 +49,7 @@ jobs:
matrix:
index: [1, 2, 3, 4, 5, 6, 7, 8, 9]
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Unit tests
Expand All @@ -77,9 +73,7 @@ jobs:
matrix:
index: [1, 2, 3, 4, 5, 6, 7, 8, 9]
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Unit tests
Expand All @@ -101,9 +95,7 @@ jobs:
ports:
- 5432:5432
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Setup local S3 bucket
Expand All @@ -126,9 +118,7 @@ jobs:
name: Field CRUD Tests SQLite
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Setup local S3 bucket
Expand Down Expand Up @@ -158,9 +148,7 @@ jobs:
ports:
- 3306:3306
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Setup local S3 bucket
Expand All @@ -183,9 +171,9 @@ jobs:
name: Testing example project
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Example unit tests
run: cd examples/testing; yarn test

Expand Down Expand Up @@ -220,9 +208,7 @@ jobs:
]
fail-fast: false
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Install Dependencies of Browsers
Expand Down Expand Up @@ -251,9 +237,7 @@ jobs:
]
fail-fast: false
steps:
- name: Checkout Repo
uses: actions/checkout@v3

- uses: actions/checkout@main
- uses: ./.github/actions/ci-setup

- name: Install Dependencies of Browsers
Expand Down
18 changes: 8 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,21 @@ jobs:
runs-on: ubuntu-latest
environment: release
steps:
- name: Checkout Repo
uses: actions/checkout@master
- uses: actions/checkout@main
with:
fetch-depth: 0
persist-credentials: false
persist-credentials: true # needed for git push

- uses: ./.github/actions/ci-setup

- name: Publish to npm
- run: yarn build

- name: npm publish, git tag, git push
uses: changesets/action@v1
with:
version: yarn no-run-version-packages
publish: yarn publish-changed
version: exit 1
publish: yarn changeset publish
createGithubReleases: false
env:
# note that we're not using the GH token provided by Actions here because Actions has a rule that Actions
# will not run as the result of another Action so CI wouldn't run on the release PRs then
# we can get around it by using a personal access token from a GH account
GITHUB_TOKEN: ${{ secrets.KEYSTONE_RELEASE_BOT_GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
45 changes: 45 additions & 0 deletions .github/workflows/publish_snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Publish (Snapshot)

on:
workflow_dispatch:
inputs:
tag:
description: 'The npm tag to publish to'
required: true

jobs:
publish_snapshot:
name: Publish (Snapshot)
runs-on: ubuntu-latest
environment: release
steps:
- uses: actions/checkout@main
with:
fetch-depth: 0
persist-credentials: true # needed for git push

- uses: ./.github/actions/ci-setup

- name: version packages
run: yarn changeset version --snapshot ${{ inputs.tag }}
env:
GITHUB_TOKEN: ${{ secrets.KEYSTONE_RELEASE_BOT_GITHUB_TOKEN }}

- name: git commit
run: |
git config --global user.name 'Keystonejs Release Bot'
git config --global user.email 'automation+keystonejs@thinkmill.com.au'
git commit -a -m 'rc'
- run: yarn build

- name: npm publish, git tag
run: yarn changeset publish --tag ${{ inputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

# reset, then push the dangling commit
- name: git push
run: |
git reset HEAD~1 --hard
git push origin --tags
10 changes: 4 additions & 6 deletions .github/workflows/version_packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ on:
workflow_dispatch:

jobs:
release_pr:
versioning:
name: Pull Request
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/checkout@main
with:
fetch-depth: 0
persist-credentials: false
Expand All @@ -20,9 +20,7 @@ jobs:

- uses: changesets/action@v1
with:
version: yarn version-packages
version: yarn ci:version-packages
env:
# note that we're not using the GH token provided by Actions here because Actions has a rule that Actions
# will not run as the result of another Action so CI wouldn't run on the release PRs then
# we can get around it by using a personal access token from a GH account
# use a different GitHub account to have the CI run on push
GITHUB_TOKEN: ${{ secrets.KEYSTONE_RELEASE_BOT_GITHUB_TOKEN }}
12 changes: 2 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@
"coverage": "jest --coverage",
"format:file": "prettier --write",
"format": "prettier --write \"**/*.{js,json,ts,tsx,md,mdx}\"",
"fresh": "yarn clean && yarn",
"clean": "rimraf \"**/node_modules\" \"**/yarn-error.log\" \"**/out.log\" \"**/.DS_Store\" \"**/dist\"",
"ci:version-packages": "yarn changeset version && cd docs && yarn remove-conditionals",
"lint:eslint": "eslint . --ext ts,tsx,js",
"lint:prettier": "prettier --check \"**/*.{js,json,ts,tsx,md,mdx}\"",
"lint:types": "tsc",
Expand All @@ -22,14 +21,8 @@
"test:debug": "node --inspect-brk ./node_modules/.bin/jest --runInBand",
"test:admin-ui": "jest tests/admin-ui-tests",
"benchmark": "yarn workspace @keystone-6/benchmarks-legacy go",
"changeset": "changeset",
"publish-changed": "yarn build && changeset publish --public",
"version-packages": "changeset version && cd docs && yarn remove-conditionals",
"no-run-version-packages": "echo \"This workflow should not be run when there are changesets on main\" && exit 1",
"build": "preconstruct build",
"prepare": "patch-package && manypkg check && preconstruct dev && yarn run --silent contributing-guide && node scripts/generate-artifacts-for-projects && cd examples/graphql-ts-gql && yarn ts-gql build",
"contributing-guide": "echo \"📝 Contributing to KeystoneJS?\" && echo \"🔗 Read the full Contributing Guide at ./CONTRIBUTING.md\"",
"npm-tag": "manypkg npm-tag",
"prepare": "patch-package && manypkg check && preconstruct dev && node scripts/generate-artifacts-for-projects && cd examples/graphql-ts-gql && yarn ts-gql build",
"update": "manypkg upgrade",
"update-project-schemas": "node scripts/generate-artifacts-for-projects update-schemas",
"generate-filters": "cd prisma-utils && yarn generate",
Expand Down Expand Up @@ -60,7 +53,6 @@
"prettier": "^2.5.0",
"react": "^18.1.0",
"react-dom": "^18.1.0",
"rimraf": "^3.0.2",
"typescript": "~4.7.4"
},
"prettier": {
Expand Down

1 comment on commit aef70b8

@vercel
Copy link

@vercel vercel bot commented on aef70b8 Oct 13, 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.