Skip to content

Commit

Permalink
Add GitHub Actions test + release scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
mjackson committed Jul 10, 2020
1 parent e9ec51d commit eb841c9
Show file tree
Hide file tree
Showing 16 changed files with 955 additions and 103 deletions.
39 changes: 0 additions & 39 deletions .github/workflows/build-and-test.yml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: release

on:
push:
tags:
- v*

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- run: echo "::set-output name=version::$(cat .nvmrc)"
id: nvmrc

- name: Setup node
uses: actions/setup-node@v1
with:
node-version: "${{ steps.nvmrc.outputs.version }}"

- run: echo "::set-output name=dir::$(yarn cache dir)"
id: yarn-cache

- name: Restore dependency cache
uses: actions/cache@v2
with:
path: "${{ steps.yarn-cache.outputs.dir }}"
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-
- name: Install dependencies
run: yarn --frozen-lockfile

- name: Build
run: yarn build

- name: Test
run: yarn test

- name: Setup npm auth
run: echo "//npm.pkg.github.com/:_authToken=${{ secrets.REGISTRY_PUBLISH_SECRET }}" > ~/.npmrc

- name: Publish
run: yarn run publish
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: test

on:
push:
branches:
- "**"
tags-ignore:
- v*

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- run: echo "::set-output name=version::$(cat .nvmrc)"
id: nvmrc

- name: Setup node
uses: actions/setup-node@v1
with:
node-version: "${{ steps.nvmrc.outputs.version }}"

- run: echo "::set-output name=dir::$(yarn cache dir)"
id: yarn-cache

- name: Restore dependency cache
uses: actions/cache@v2
with:
path: "${{ steps.yarn-cache.outputs.dir }}"
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-
- name: Install dependencies
run: yarn --frozen-lockfile

- name: Build
run: yarn build

- name: Test
run: yarn test
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@remix-run:registry=https://npm.pkg.github.com
40 changes: 34 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
Welcome to Remix!

GitHub Actions suck!

// in .npmrc
@remix-run:registry=https://npm.pkg.github.com
## Development

// in the cli
yarn add @remix-run/react @remix-run/express
```
# install everything
yarn install
# run the build
yarn build
# run the tests
yarn test
# run the tests for a specific package
yarn test react
# run the tests in watch mode
yarn test react --watch
# cut a release
yarn run version major|minor|patch|prerelease [prereleaseId]
yarn publish
# or
git push origin --follow-tags
```

## For Users

yarn add remix
remix register
```
# in ~/.npmrc
//npm.pkg.github.com/:_authToken=GITHUB_PERSONAL_ACCESS_TOKEN
# in project .npmrc
@remix-run:registry=https://npm.pkg.github.com
# to install
yarn add @remix-run/react @remix-run/express
```
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
"type": "module",
"scripts": {
"clean": "git clean -fdX .",
"test": "jest",
"build": "node ./scripts/build.js",
"watch": "node ./scripts/watch.js"
"publish": "node ./scripts/publish.js",
"test": "node ./scripts/test.js",
"version": "node ./scripts/version.js"
},
"workspaces": [
"packages/core",
Expand All @@ -24,6 +25,7 @@
"@typescript-eslint/eslint-plugin": "2.x",
"@typescript-eslint/parser": "2.x",
"babel-eslint": "10.x",
"chalk": "^4.1.0",
"eslint": "6.x",
"eslint-config-react-app": "^5.2.1",
"eslint-plugin-flowtype": "4.x",
Expand All @@ -33,19 +35,22 @@
"eslint-plugin-react-hooks": "2.x",
"history": "^5.0.0",
"jest": "^26.0.1",
"jsonfile": "^6.0.1",
"prettier": "^2.0.5",
"prompt-confirm": "^2.0.4",
"react": "0.0.0-experimental-33c3af284",
"react-dom": "0.0.0-experimental-33c3af284",
"react-router-dom": "0.0.0-experimental-ffd8c7d0",
"react-test-renderer": "0.0.0-experimental-33c3af284",
"rollup": "^2.21.0",
"semver": "^7.3.2",
"typescript": "^3.9.6"
},
"eslintConfig": {
"extends": "react-app"
},
"prettier": {
"arrowParens": "avoid",
"trailingComma": "none"
},
"eslintConfig": {
"extends": "react-app"
}
}
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"name": "@remix-run/core",
"version": "0.0.0"
"version": "0.0.2",
"repository": "https://github.com/remix-run/packages"
}
6 changes: 5 additions & 1 deletion packages/express/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{
"name": "@remix-run/express",
"version": "0.0.0"
"version": "0.0.2",
"repository": "https://github.com/remix-run/packages",
"dependencies": {
"@remix-run/core": "0.0.2"
}
}
3 changes: 2 additions & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "@remix-run/react",
"version": "0.0.0",
"version": "0.0.2",
"repository": "https://github.com/remix-run/packages",
"peerDependencies": {
"history": ">=5",
"react": "0.0.0-experimental-33c3af284",
Expand Down
41 changes: 24 additions & 17 deletions scripts/build.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,33 @@
import { exec } from "./utils.js";
import { exec } from "child_process";
import { promisify } from "util";

async function build() {
await exec("tsc -b");
const x = promisify(exec);

await exec("mkdir -p build/@remix-run");
async function run() {
await x("tsc -b");

await Promise.all([
exec("cp -r .tsc-output/core build/@remix-run/core"),
exec("cp packages/core/package.json build/@remix-run/core/package.json"),
await x("mkdir -p build/@remix-run");

exec("cp -r .tsc-output/express build/@remix-run/express"),
exec(
"cp packages/express/package.json build/@remix-run/express/package.json"
),
await x("cp -r .tsc-output/core build/@remix-run/core");
await x("cp packages/core/package.json build/@remix-run/core/package.json");

exec("cp -r .tsc-output/react build/@remix-run/react"),
exec("cp packages/react/package.json build/@remix-run/react/package.json")
]);
await x("cp -r .tsc-output/express build/@remix-run/express");
await x(
"cp packages/express/package.json build/@remix-run/express/package.json"
);

await x("cp -r .tsc-output/react build/@remix-run/react");
await x("cp packages/react/package.json build/@remix-run/react/package.json");

return 0;
}

build().then(code => {
process.exit(code);
});
run().then(
code => {
process.exit(code);
},
error => {
console.error(error);
process.exit(1);
}
);
58 changes: 58 additions & 0 deletions scripts/publish.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import path from "path";
import { promises as fsp } from "fs";
import { exec, spawn } from "child_process";
import { promisify } from "util";
import { fileURLToPath } from "url";

const dirname = path.dirname(fileURLToPath(import.meta.url));
const buildDir = path.resolve(dirname, "../build/@remix-run");

const x = promisify(exec);

function invariant(cond, message) {
if (!cond) throw new Error(message);
}

function npm(args, options) {
return new Promise((accept, reject) => {
spawn("npm", args, options).on("close", code => {
code === 0 ? accept() : reject();
});
});
}

async function getTaggedVersion() {
let output = (await x("git tag --list --points-at HEAD")).toString().trim();
return output.replace(/^v/g, "");
}

async function run() {
// 0. Make sure there's a current tag
let taggedVersion = await getTaggedVersion();
invariant(
taggedVersion !== "",
`Missing release version. Run the version script first.`
);

// 1. Publish all packages, starting with core
let buildNames = await fsp.readdir(buildDir);
buildNames.sort((a, b) => (a === "core" ? -1 : 0));

for (let name of buildNames) {
await npm(["publish", path.join(buildDir, name)], {
stdio: "inherit"
});
}

return 0;
}

run().then(
code => {
process.exit(code);
},
error => {
console.error(error);
process.exit(1);
}
);
Loading

0 comments on commit eb841c9

Please sign in to comment.