Skip to content

Commit

Permalink
Merge pull request #355 from FormidableLabs/ci-provenance
Browse files Browse the repository at this point in the history
GitHub Actions release workflow addition
  • Loading branch information
paulmarsicloud committed May 23, 2023
2 parents 47e25db + 72f6eee commit 824d61d
Show file tree
Hide file tree
Showing 6 changed files with 1,158 additions and 17 deletions.
11 changes: 11 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.3.0/schema.json",
"changelog": [
"@svitejs/changesets-changelog-github-compact",
{
"repo": "FormidableLabs/serverless-jetpack"
}
],
"access": "public",
"baseBranch": "master"
}
5 changes: 5 additions & 0 deletions .changeset/good-mice-float.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"serverless-jetpack": patch
---

Adding GitHub release workflow
41 changes: 41 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Release
on:
push:
branches:
- master
jobs:
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
issues: write
repository-projects: write
deployments: write
packages: write
pull-requests: write
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v3
with:
node-version: 18

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build
run: yarn build

- name: Unit Tests
run: yarn test

- name: PR or Publish
id: changesets
uses: changesets/action@v1
with:
version: yarn changeset version
publish: yarn changeset publish
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
53 changes: 51 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,62 @@ $ vim README.md
$ yarn run check
```

## Releasing a new version to NPM
### Using changesets

_Only for project administrators_.
Our official release path is to use automation to perform the actual publishing of our packages. The steps are to:

1. A human developer adds a changeset. Ideally this is as a part of a PR that will have a version impact on a package.
2. On merge of a PR our automation system opens a "Version Packages" PR.
3. On merging the "Version Packages" PR, the automation system publishes the packages.

Here are more details:

### Add a changeset

When you would like to add a changeset (which creates a file indicating the type of change), in your branch/PR issue this command:

```sh
$ yarn changeset
```

to produce an interactive menu. Navigate the packages with arrow keys and hit `<space>` to select 1+ packages. Hit `<return>` when done. Select semver versions for packages and add appropriate messages. From there, you'll be prompted to enter a summary of the change. Some tips for this summary:

1. Aim for a single line, 1+ sentences as appropriate.
2. Include issue links in GH format (e.g. `#123`).
3. You don't need to reference the current pull request or whatnot, as that will be added later automatically.

After this, you'll see a new uncommitted file in `.changesets` like:

```sh
$ git status
# ....
Untracked files:
(use "git add <file>..." to include in what will be committed)
.changeset/flimsy-pandas-marry.md
```

Review the file, make any necessary adjustments, and commit it to source. When we eventually do a package release, the changeset notes and version will be incorporated!

### Creating versions

On a merge of a feature PR, the changesets GitHub action will open a new PR titled `"Version Packages"`. This PR is automatically kept up to date with additional PRs with changesets. So, if you're not ready to publish yet, just keep merging feature PRs and then merge the version packages PR later.

### Publishing packages

On the merge of a version packages PR, the changesets GitHub action will publish the packages to npm.

### Manually Releasing a new version to NPM

<details>
<summary>
<i>Only for project administrators</i>
</summary>

1. Update `CHANGELOG.md`, following format for previous versions
2. Commit as "Changes for version VERSION"
3. Run `npm version patch` (or `minor|major|VERSION`) to run tests and lint,
build published directories, then update `package.json` + add a git tag.
4. Run `npm publish` and publish to NPM if all is well.
5. Run `git push && git push --tags`

</details>
5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
"trace-deps": "^0.4.0"
},
"devDependencies": {
"@changesets/cli": "^2.26.1",
"@svitejs/changesets-changelog-github-compact": "^0.1.1",
"adm-zip": "^0.5.5",
"babel-eslint": "^10.1.0",
"chai": "^4.3.4",
Expand All @@ -72,5 +74,8 @@
"sinon": "^11.1.1",
"sinon-chai": "^3.7.0",
"strip-ansi": "^6.0.0"
},
"publishConfig": {
"provenance": true
}
}

0 comments on commit 824d61d

Please sign in to comment.