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

chore: add auto-deployment via Changesets #74

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
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)
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/[email protected]/schema.json",
"changelog": [
"@changesets/cli/changelog",
{ "repo": "web-std/io" }
],
"commit": false,
"fixed": [],
"linked": [],
"access": "public",
"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,102 +1,47 @@
name: release
on:
workflow_dispatch:
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: "@web-std/${{ 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: "@web-std/${{ 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": "@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",
"@web-std/stream": "1.0.0"
"@web-std/stream": "^1.0.3",
"web-encoding": "1.1.5"
},
"author": "Irakli Gozalishvili <[email protected]> (https://gozala.io)",
"repository": "https://github.com/web-std/io",
"license": "MIT",
"devDependencies": {
"@types/node": "15.0.2",
"@web-std/fetch": "^3.0.0",
"@web-std/fetch": "^4.1.2",
"git-validate": "2.2.4",
"husky": "^6.0.0",
"lint-staged": "^11.0.0",
Expand Down
6 changes: 2 additions & 4 deletions packages/fetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@
"@types/chai-as-promised": "^7.1.5",
"@types/chai-string": "^1.4.2",
"@types/mocha": "^9.1.0",
"abort-controller": "^3.0.0",
"@web-std/file": "^3.0.2",
"abortcontroller-polyfill": "^1.7.1",
"busboy": "^0.3.1",
"c8": "^7.3.0",
Expand All @@ -92,7 +90,7 @@
"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",
"typescript": "^4.4.4",
"xo": "^0.33.1"
Expand All @@ -101,7 +99,7 @@
"@web-std/blob": "^3.0.3",
"@web-std/file": "^3.0.2",
"@web-std/form-data": "^3.0.2",
"@web-std/stream": "^1.0.1",
"@web-std/stream": "^1.0.3",
"@web3-storage/multipart-parser": "^1.0.0",
"abort-controller": "^3.0.0",
"data-uri-to-buffer": "^3.0.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/file/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"license": "MIT",
"devDependencies": {
"@types/node": "15.0.2",
"@web-std/fetch": "^3.0.0",
"@web-std/fetch": "^4.1.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 @@ -36,7 +36,7 @@
"devDependencies": {
"@types/node": "15.0.2",
"@web-std/blob": "^3.0.0",
"@web-std/fetch": "^3.0.0",
"@web-std/fetch": "^4.1.2",
"@web-std/file": "^3.0.0",
"git-validate": "2.2.4",
"husky": "^6.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
Loading