Skip to content

Commit

Permalink
chore: Add auto-deployment via Changesets
Browse files Browse the repository at this point in the history
  • Loading branch information
chaance committed May 12, 2022
1 parent 565f94e commit f5a5e15
Show file tree
Hide file tree
Showing 10 changed files with 847 additions and 120 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)
14 changes: 14 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"$schema": "https://unpkg.com/@changesets/config@2.0.0/schema.json",
"changelog": [
"@changesets/cli/changelog",
{ "repo": "remix-run/web-std-io" }
],
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch",
"ignore": []
}
121 changes: 33 additions & 88 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,101 +1,46 @@
name: release
on:
push:
branches:
- main
name: release
concurrency: ${{ github.workflow }}-${{ github.ref }}
env:
CI: true
jobs:
changeFinder:
runs-on: ubuntu-latest
outputs:
nodePaths: ${{ steps.interrogate.outputs.nodePaths }}
steps:
- uses: actions/checkout@v2
- id: interrogate
uses: actions/github-script@v4
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
const {execSync} = require('child_process');
const [owner, repo] = process.env.GITHUB_REPOSITORY.split('/');
const latestRelease = await github.repos.getLatestRelease({
owner,
repo
});
console.log(`latest release: ${JSON.stringify(latestRelease.data)}`);
execSync('git pull --tags');
execSync(`git reset --hard ${latestRelease.data.tag_name}`);
const status = execSync(`git diff --name-only origin/main`, { encoding: 'utf-8'});
console.log(status);
const changes = status.split('\n');
let nodePaths = new Set();
for (const change of changes) {
if (change.startsWith('packages/')) {
const [,library] = change.split('/');
nodePaths.add(library);
};
}
nodePaths = Array.from(nodePaths);
if(nodePaths.length === 0){
console.log(`::warning::No changes found, release will be skipped.`)
}
console.log(`::set-output name=nodePaths::${JSON.stringify(nodePaths)}`);
release-pr:
runs-on: ubuntu-latest
needs: changeFinder
if: ${{ fromJson(needs.changeFinder.outputs.nodePaths)[0] != '' }}
strategy:
fail-fast: false
matrix:
package: ${{fromJson(needs.changeFinder.outputs.nodePaths)}}
steps:
- uses: google-github-actions/release-please-action@v2
id: release-please
with:
path: packages/${{ matrix.package }}
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
package-name: "@remix-run/web-${{ matrix.package }}"
monorepo-tags: true
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"refactor","section":"Changes","hidden":false},{"type":"chore","section":"Changes","hidden":false}]'
command: release-pr
release:
name: release
if: ${{ github.repository == 'remix-run/web-std-io' }}
runs-on: ubuntu-latest
needs: changeFinder
if: ${{ fromJson(needs.changeFinder.outputs.nodePaths)[0] != '' }}
strategy:
fail-fast: false
matrix:
package: ${{fromJson(needs.changeFinder.outputs.nodePaths)}}
steps:
- uses: GoogleCloudPlatform/release-please-action@v2
id: release
with:
path: packages/${{ matrix.package }}
token: ${{ secrets.GITHUB_TOKEN }}
release-type: node
package-name: "@remix-run/web-${{ matrix.package }}"
monorepo-tags: true
changelog-types: '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"refactor","section":"Changes","hidden":false},{"type":"chore","section":"Changes","hidden":false}]'
command: github-release
# The logic below handles the npm publication:
- name: Checkout
uses: actions/checkout@v2
# these if statements ensure that a publication only occurs when
# a new release is created:
if: ${{ steps.release.outputs.release_created }}
- name: Setup
uses: actions/setup-node@v2
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
if: ${{ steps.release.outputs.release_created }}
cache: 'yarn'
- name: Install
uses: bahmutov/npm-install@v1
if: ${{ steps.release.outputs.release_created }}
- name: Publish
if: ${{ steps.release.outputs.release_created }}
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_AUTH_TOKEN}}
run: yarn install --frozen-lockfile
- name: Auth
run: |
cd packages/${{ matrix.package }}
npm publish --access=public
echo "registry=https://registry.npmjs.org" >> ~/.npmrc
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc
# This action has two responsibilities. The first time the workflow runs
# (initial push to `main`) it will create a new branch and then PR back
# to `main` with the related changes for the new version. After the PR
# is merged, the workflow will run again and this action will publish to
# npm.
- name: PR / Publish
id: changesets
uses: changesets/action@v1
with:
version: yarn version-bump
commit: "chore: Update version for release"
title: "chore: Update version for release"
publish: yarn release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
11 changes: 11 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "@remix-run/web-std-io",
"private": true,
"workspaces": [
"packages/blob",
Expand All @@ -8,6 +9,10 @@
"packages/stream"
],
"scripts": {
"changeset": "changeset",
"release": "changeset publish",
"version-bump": "changeset version",
"postinstall": "manypkg fix",
"prepare": "yarn prepare:blob && yarn prepare:file && yarn prepare:form-data && yarn prepare:fetch",
"prepare:blob": "yarn --cwd packages/blob prepare",
"prepare:file": "yarn --cwd packages/file prepare",
Expand All @@ -19,5 +24,11 @@
"test:form-data": "yarn --cwd packages/form-data test",
"test:fetch": "yarn --cwd packages/fetch test",
"test:stream": "yarn --cwd packages/stream test"
},
"dependencies": {
"@changesets/changelog-github": "0.4.4",
"@changesets/cli": "^2.22.0",
"@manypkg/cli": "0.19.1",
"@manypkg/get-packages": "^1.1.3"
}
}
6 changes: 3 additions & 3 deletions packages/blob/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
}
},
"dependencies": {
"web-encoding": "1.1.5",
"@remix-run/web-stream": "^1.0.3"
"@remix-run/web-stream": "^1.0.3",
"web-encoding": "1.1.5"
},
"author": "Irakli Gozalishvili <dev@gozala.io> (https://gozala.io)",
"repository": "https://github.com/remix-run/web-std-io",
"license": "MIT",
"devDependencies": {
"@types/node": "15.0.2",
"@remix-run/web-fetch": "^4.1.1",
"@types/node": "15.0.2",
"git-validate": "2.2.4",
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
Expand Down
12 changes: 6 additions & 6 deletions packages/fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@
"homepage": "https://github.com/remix-run/web-std-io",
"devDependencies": {
"@types/chai": "^4.3.0",
"@types/mocha": "^9.1.0",
"@types/chai-as-promised": "^7.1.5",
"@types/chai-string": "^1.4.2",
"@types/mocha": "^9.1.0",
"abort-controller": "^3.0.0",
"abortcontroller-polyfill": "^1.7.1",
"busboy": "^0.3.1",
Expand All @@ -91,18 +91,18 @@
"formdata-node": "^2.4.0",
"mocha": "^8.1.3",
"p-timeout": "^3.2.0",
"rollup": "^2.26.10",
"rollup": "2.47.0",
"tsd": "^0.13.1",
"xo": "^0.33.1",
"typescript": "^4.4.4"
"typescript": "^4.4.4",
"xo": "^0.33.1"
},
"dependencies": {
"@remix-run/web-blob": "^3.0.4",
"@remix-run/web-form-data": "^3.0.2",
"@remix-run/web-stream": "^1.0.3",
"@web3-storage/multipart-parser": "^1.0.0",
"data-uri-to-buffer": "^3.0.1",
"mrmime": "^1.0.0",
"@web3-storage/multipart-parser": "^1.0.0"
"mrmime": "^1.0.0"
},
"esm": {
"sourceMap": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/file/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
"repository": "https://github.com/remix-run/web-std-io",
"license": "MIT",
"devDependencies": {
"@types/node": "15.0.2",
"@remix-run/web-fetch": "^4.1.1",
"@types/node": "15.0.2",
"git-validate": "2.2.4",
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/form-data/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
"repository": "https://github.com/remix-run/web-std-io",
"license": "MIT",
"devDependencies": {
"@types/node": "15.0.2",
"@remix-run/web-blob": "^3.0.4",
"@remix-run/web-fetch": "^4.1.1",
"@remix-run/web-file": "^3.0.2",
"@types/node": "15.0.2",
"git-validate": "2.2.4",
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/stream/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"prettier": "^2.3.0",
"rimraf": "3.0.2",
"typescript": "^4.4.4",
"uvu": "^0.5.2"
"uvu": "0.5.2"
},
"scripts": {
"typecheck": "tsc --build",
Expand Down

0 comments on commit f5a5e15

Please sign in to comment.