Skip to content

Commit

Permalink
Merge pull request #681 from primer/setup_changesets_workflow
Browse files Browse the repository at this point in the history
Setting up a changesets based release workflow
  • Loading branch information
jonrohan authored Oct 22, 2021
2 parents b5bdabb + c394d9a commit 2af6cbf
Show file tree
Hide file tree
Showing 12 changed files with 1,339 additions and 417 deletions.
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/[email protected]/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.

🎉 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
16 changes: 12 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
{
"private": true,
"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

0 comments on commit 2af6cbf

Please sign in to comment.