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

Setting up a changesets based release workflow #681

Merged
merged 28 commits into from
Oct 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d2c0342
Create changeset workflow
jonrohan Oct 19, 2021
1c7ba01
Create funny-kings-watch.md
jonrohan Oct 22, 2021
8719911
Merge pull request #1 from primer/release_changesets
jonrohan Oct 22, 2021
d67b0b9
Update release.yml
jonrohan Oct 22, 2021
54ce41e
Update config.json
jonrohan Oct 22, 2021
d0a1c48
Fix versioning
jonrohan Oct 22, 2021
533e78e
rename
jonrohan Oct 22, 2021
fae0616
rename
jonrohan Oct 22, 2021
16d70b5
fix changeset
jonrohan Oct 22, 2021
9056681
change to script/version
jonrohan Oct 22, 2021
8d7aa84
setup ruby
jonrohan Oct 22, 2021
d2fdfc4
just yarn
jonrohan Oct 22, 2021
aba86d0
Bundle each folder
jonrohan Oct 22, 2021
ca299ba
gemfile
jonrohan Oct 22, 2021
02996b7
remove gemspec
jonrohan Oct 22, 2021
24abd8b
Version Packages
github-actions[bot] Oct 22, 2021
c25611e
Merge pull request #2 from primer/changeset-release/main
jonrohan Oct 22, 2021
3fa1b5e
Change publish
jonrohan Oct 22, 2021
dec7de1
Fixing for octicons repo
jonrohan Oct 22, 2021
1c4caf4
Merge branch 'main' into setup_changesets_workflow
jonrohan Oct 22, 2021
7c7a21d
Remove build on push, and trigger on release published
jonrohan Oct 22, 2021
75865ac
Updating release docs
jonrohan Oct 22, 2021
93764f6
adding eslint-plugin-prettier@latest
jonrohan Oct 22, 2021
08cb24b
Fix lint
jonrohan Oct 22, 2021
ec692a3
Update and rename build.yml to publish.yml
jonrohan Oct 22, 2021
8facd8b
Update package.json
jonrohan Oct 22, 2021
81c358d
Update CONTRIBUTING.md
jonrohan Oct 22, 2021
c394d9a
Adding changeset
jonrohan Oct 22, 2021
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.1/schema.json",
"changelog": ["@changesets/changelog-github", {"repo": "primer/octicons"}],
"commit": false,
"linked": [],
"access": "public",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
5 changes: 5 additions & 0 deletions .changeset/eighty-seas-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/octicons': patch
---

Adding changesets workflow to octicons for releasing.
22 changes: 3 additions & 19 deletions .github/workflows/build.yml → .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
on:
push:
branches:
- main
pull_request:
branches-ignore:
- 'dependabot/**'
name: Octicons Build
release:
types: [published]
name: Octicons Publish
jobs:
setup:
runs-on: ubuntu-latest
Expand All @@ -14,8 +10,6 @@ jobs:
- uses: actions/setup-node@master
with:
node-version: '10.x'
- name: Version
uses: ./.github/actions/version
- run: npm install
- run: npm run build
- run: cp -r icons lib/build/svg
Expand All @@ -28,8 +22,6 @@ jobs:
needs: setup
steps:
- uses: actions/checkout@master
- name: Version
uses: ./.github/actions/version
- uses: actions/download-artifact@master
with:
name: octicons
Expand All @@ -49,8 +41,6 @@ jobs:
needs: gem
steps:
- uses: actions/checkout@master
- name: Version
uses: ./.github/actions/version
- uses: actions/download-artifact@master
with:
name: octicons
Expand All @@ -69,8 +59,6 @@ jobs:
needs: gem
steps:
- uses: actions/checkout@master
- name: Version
uses: ./.github/actions/version
- uses: actions/download-artifact@master
with:
name: octicons
Expand All @@ -89,8 +77,6 @@ jobs:
needs: setup
steps:
- uses: actions/checkout@master
- name: Version
uses: ./.github/actions/version
- uses: actions/download-artifact@master
with:
name: octicons
Expand All @@ -105,8 +91,6 @@ jobs:
needs: setup
steps:
- uses: actions/checkout@master
- name: Version
uses: ./.github/actions/version
- uses: actions/download-artifact@master
with:
name: octicons
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Release
on:
push:
branches:
- 'main'
- 'next_major'
jobs:
release:
name: Final
if: ${{ github.repository == 'primer/octicons' }}

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: 14.x

- name: Setup Ruby
uses: actions/setup-ruby@v1
with:
ruby-version: 3.0.x

- name: Install dependencies
run: |
yarn
bundle install
- name: Create release pull request or publish to npm
id: changesets
uses: changesets/action@master
with:
title: Release Tracking
version: yarn changeset:version
# This is a hack to make the changeset action think we npm published, so that it creates the github release
publish: echo "New tag:"
env:
GITHUB_TOKEN: ${{ secrets.GPR_AUTH_TOKEN_SHARED }}
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN_SHARED }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
.env
node_modules
vendor
Gemfile.lock

# Ignore build/export artifacts
lib/**/build/
Expand Down
41 changes: 4 additions & 37 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,45 +95,12 @@ If everything looks good, a maintainer will approve and merge the pull request w

Once submitted changes have been agreed upon, these instructions will guide maintainers through releasing changes.

### 1. Create a release branch in the [primer/octicons](https://github.com/primer/octicons) repository.
Releases are managed by 🦋 [Changesets](https://github.com/atlassian/changesets#documentation) which is a great tool for managing major/minor/patch bumps and changelogs. More info can be found in our [how we work docs](https://github.com/github/design-infrastructure/blob/main/how-we-work/engineering/changesets.md#using-changesets-to-prepare-and-publish-a-release).

```shell
git checkout -b release-x.y.z
```

In the context of Octicons, the version number is updated as follows:

- Breaking changes to the library or workflow, renaming or removing an icon would all be considered a **major update**.
- Adding a new icon would be considered a **minor update**.
- Fixing an icon would be considered a **patch**.

Reach out in the #design-systems Slack channel if you're unsure.

### 2. Update the [CHANGELOG](https://github.com/primer/octicons/blob/main/CHANGELOG.md) describing the changes in this release.

When adding changes, be sure to provide a link to any of the relevant PRs merged into the release.

### 3. Update the version in code base

Find and replace the version number of the current release with the version number of the new release. Exclude anything that does relate directly to the Octicons version. Examples of excluded items include `yargs-parser` and `testing-library_react`.

### 4. Create a release PR

When creating the release PR, include the changes written in the CHANGELOG in the description. We advise changing any bulleted item into a checkbox item. After each update is merged into the release PR, check each item as complete.

### 5. Merge
When all of the checks have passed and the release PR has been approved, merge the new release to the main branch.

### 6. Draft new release
- On the **Code** tab, click **Releases** in the repo sidebar.
- Click **Draft a new release**.
- Tag the release with the new version number (e.g. `v10.1.0`).
- Title the release with the new version number and paste in the changes that were added to the CHANGELOG.
- Click **Publish release**.

**Example:**
We have the [changeset-bot comment on new pull requests](https://github.com/changesets/bot#readme) asking contributors or maintainers to add a changeset file, which will become the markdown supported changelog entry for the change.

![image](https://user-images.githubusercontent.com/10384315/91103190-c6171e80-e61f-11ea-8396-7138996cff30.png)
When a pull request is approved merge it into the `main` branch. The changeset action will then create a Release pull request that includes this new pull request.

Once maintainers have agreed and are satisifed with the release. Merge the Release pull request. Changesets will then publish a new GitHub release to the repository with the changelog and new version number. A second action will be triggered by this release and publish the new versions to npm and rubygems.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a link to this document in here somewhere?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nice I didn't realize we had these docs 👍🏻


🎉 Congratulations! The new release has been published.
8 changes: 8 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
source "https://rubygems.org"

group :development, :test do
gem "minitest"
gem "rake"
gem "rubocop", "0.59"
gem "rubocop-github", "0.12.0"
end
Copy link
Contributor

Choose a reason for hiding this comment

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

Not too familiar with how Gemfiles work. What does this do?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's a bit like package.json, I needed to pull these dev dependencies up to the root so I could run bundle rake in each of the folders.

16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
{
"private": true,
Copy link
Member Author

Choose a reason for hiding this comment

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

I'd rather keep this private, but changesets will skip if they find private true here, so I'm trying to avoid publishing main package.json file by adding

+  "publishConfig": {
+    "registry": "http://localhost:4873"
+  },

Copy link
Contributor

Choose a reason for hiding this comment

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

Where does that port number come from?

Copy link
Member Author

@jonrohan jonrohan Oct 22, 2021

Choose a reason for hiding this comment

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

I was wanting to point to anything other than npm and co-pilot suggested this 😆 The point is to fail it out so people don't npm publish from their terminal.

I'll accept whatever you think here.

Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, should we just say like "no registry" or something to make it clear that this is a noop?

Using http://localhost:4873 feels like it's pointing to something real

Copy link
Member Author

Choose a reason for hiding this comment

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

"publishConfig": {
    "registry": "no registry, don't publish from this package.json."
},

"name": "@primer/octicons",
"version": "16.1.0",
"publishConfig": {
"registry": "no registry, don't publish from this package.json."
},
"scripts": {
"version": "script/version",
"changeset:version": "changeset version && script/version",
"test": "ava -v tests/*.js",
"lint": "eslint tests",
"build": "script/build.js --input icons/**/*.svg --output lib/build/data.json",
"start": "cd docs && npm run develop",
"svgo": "svgo icons --config .svgo.yml"
},
"dependencies": {
"@changesets/changelog-github": "0.4.1",
"@changesets/cli": "2.17.0",
"@github/prettier-config": "0.0.4",
"ava": "2.1.0",
"braces": "2.3.1",
"cheerio": "1.0.0-rc.3",
"eslint": "7.24.0",
"eslint-plugin-github": "4.1.3",
"eslint": "8.0.1",
"eslint-plugin-github": "4.3.2",
"eslint-plugin-prettier": "4.0.0",
"execa": "4.0.0",
"fs-extra": "7.0.1",
"globby": "11.0.0",
Expand All @@ -39,7 +46,8 @@
"requireConfigFile": false
},
"rules": {
"github/no-then": 0
"github/no-then": 0,
"eslint-comments/no-use": 0
}
}
}
2 changes: 1 addition & 1 deletion tests/build.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* eslint-env node */
/* eslint-disable import/no-commonjs */
const path = require('path')
const test = require('ava')
const execa = require('execa')
Expand Down
3 changes: 3 additions & 0 deletions tests/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/* eslint-disable import/no-commonjs */
/* eslint-disable i18n-text/no-en */

const test = require('ava')
const fs = require('fs-extra')
const globby = require('globby')
Expand Down
Loading