Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set up changesets #10

Merged
merged 2 commits into from
Dec 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .changeset/README.md
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)
10 changes: 10 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://unpkg.com/@changesets/config@1.6.3/schema.json",
"changelog": ["@changesets/changelog-github", {"repo": "primer/behaviors"}],
"commit": false,
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/great-impalas-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/behaviors': patch
---

Set up changesets
25 changes: 25 additions & 0 deletions .github/workflows/check_for_changeset.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Check for changeset

on:
pull_request:
types:
# On by default if you specify no types.
- "opened"
- "reopened"
- "synchronize"
# For `skip-label` only.
- "labeled"
- "unlabeled"

jobs:
check-for-changeset:
name: Check for changeset
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: "Check for changeset"
uses: brettcannon/check-for-changed-files@v1
with:
file-pattern: ".changeset/*.md"
skip-label: "skip changeset"
failure-message: "No changeset found. If these changes should not result in a new version, apply the ${skip-label} label to this pull request. If these changes should result in a version bump, please add a changeset https://git.io/J6QvQ"
35 changes: 35 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Release
on:
push:
branches:
- main
jobs:
release:
name: Release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0
persist-credentials: false

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16

- name: Install dependencies
run: npm ci

- name: Create release pull request or publish to npm
id: changesets
uses: changesets/action@master
with:
title: Release Tracking
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: npm run release
env:
GITHUB_TOKEN: ${{ secrets.GPR_AUTH_TOKEN_SHARED }}
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
70 changes: 70 additions & 0 deletions .github/workflows/release_canary.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Release
on:
push:
branches-ignore:
- 'main'
- 'changeset-release/main'
# To avoid unnecessary noise, we don't create canary releases when these paths change:
paths-ignore:
- '.changeset/**'
- '.devcontainer/**'
- '.github/**'
- '.storybook/**'
- '.vscode/**'
- 'docs/**'

jobs:
release-canary:
name: Canary
if: ${{ github.repository == 'primer/behaviors' }}

runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Create .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}

- name: Publish canary version
run: |
echo "$( jq '.version = "0.0.0"' package.json )" > package.json
echo -e "---\n'@primer/behaviors': patch\n---\n\nFake entry to force publishing" > .changeset/force-snapshot-release.md
yarn changeset version --snapshot
yarn changeset publish --tag canary
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Output canary version number
uses: actions/github-script@v4.0.2
with:
script: |
const package = require(`${process.env.GITHUB_WORKSPACE}/package.json`)
github.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: 'success',
context: `Published ${package.name}`,
description: package.version,
target_url: `https://unpkg.com/${package.name}@${package.version}/`
})
60 changes: 60 additions & 0 deletions .github/workflows/release_candidate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Release
on:
push:
branches:
- 'changeset-release/main'

jobs:
release-candidate:
name: Candidate
if: ${{ github.repository == 'primer/behaviors' }}

runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16

- name: Install dependencies
run: npm ci

- name: Build
run: npm run build

- name: Create .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}

- name: Publish release candidate
run: |
version=$(jq -r .version package.json)
echo "$( jq ".version = \"$(echo $version)-rc.$(git rev-parse --short HEAD)\"" package.json )" > package.json
yarn publish --tag next
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Output release candidate version number
uses: actions/github-script@v4.0.2
with:
script: |
const package = require(`${process.env.GITHUB_WORKSPACE}/package.json`)
github.repos.createCommitStatus({
owner: context.repo.owner,
repo: context.repo.repo,
sha: context.sha,
state: 'success',
context: `Published ${package.name}`,
description: package.version,
target_url: `https://unpkg.com/${package.name}@${package.version}/`
})
Loading