Skip to content

Commit

Permalink
ci: switch to github actions for v4 releases (#377)
Browse files Browse the repository at this point in the history
  • Loading branch information
mcous committed Mar 12, 2022
1 parent eb8c180 commit 507f052
Show file tree
Hide file tree
Showing 7 changed files with 137 additions and 184 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
@@ -0,0 +1,42 @@
name: continuous integration
on: [push, pull_request]

jobs:
test:
strategy:
matrix:
node-version: ['10', '12', '14']
name: unit tests on node ${{ matrix.node-version }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
- run: yarn install --frozen-lockfile
- run: yarn test
- run: yarn coverage
- uses: codecov/codecov-action@v2

lint:
name: lint and format checks
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: '12'
- run: yarn install --frozen-lockfile
- run: yarn lint
- run: yarn format --check

build:
name: build assets and type definitions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: '12'
- run: yarn install --frozen-lockfile
- run: yarn build:all
79 changes: 79 additions & 0 deletions .github/workflows/publish.yml
@@ -0,0 +1,79 @@
name: publish
on:
push:
branches: main
tags: v*

jobs:
test:
name: pre-publish test run
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: '12'
- run: yarn install --frozen-lockfile
- run: yarn test

publish:
if: startsWith(github.ref, 'refs/tags/v')
name: publish packages to npm and site to S3
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: '12'
registry-url: 'https://registry.npmjs.org'

- run: yarn install --frozen-lockfile

- name: build assets
run: yarn build:all
env:
MIXPANEL_ID: ${{ secrets.MIXPANEL_TOKEN }}

- name: get npm release tag
id: npm_tag
run: echo "::set-output name=tag::$(node scripts/get-npm-tag.js ${{ github.ref }})"

- name: publish to npm with lerna
run: npm run publish:npm -- --npm-tag ${{ steps.npm_tag.outputs.tag }}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: publish to production S3
run: yarn publish:s3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_S3_REGION: us-east-2
AWS_S3_BUCKET: tracespace.io

publish-staging:
name: publish staging site to s3
runs-on: ubuntu-latest
needs: test
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v2
with:
node-version: '12'
registry-url: 'https://registry.npmjs.org'

- run: yarn install --frozen-lockfile

- name: build assets
run: yarn build:all
env:
MIXPANEL_ID: ${{ secrets.MIXPANEL_STAGING_TOKEN }}

- name: publish to S3
run: yarn publish:s3
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_S3_REGION: us-east-2
AWS_S3_BUCKET: staging.tracespace.io
74 changes: 0 additions & 74 deletions .travis.yml

This file was deleted.

6 changes: 0 additions & 6 deletions README.md
@@ -1,21 +1,15 @@
# tracespace

[![ci][ci-badge]][ci]
[![coverage][coverage-badge]][coverage]
[![dev dependencies][dev-dependencies-badge]][dev-dependencies]
[![chat][chat-badge]][chat]

> PCB visualization tools for Node.js and the browser
tracespace is an open-source collection of tools to make looking at circuit boards on the internet easier.

[ci]: https://travis-ci.org/tracespace/tracespace
[coverage]: https://codecov.io/gh/tracespace/tracespace
[dev-dependencies]: https://david-dm.org/tracespace/tracespace?type=dev
[chat]: https://gitter.im/tracespace/Lobby
[ci-badge]: https://flat.badgen.net/travis/tracespace/tracespace
[coverage-badge]: https://flat.badgen.net/codecov/c/github/tracespace/tracespace
[dev-dependencies-badge]: https://flat.badgen.net/david/dev/tracespace/tracespace
[chat-badge]: https://flat.badgen.net/badge/chat/on%20gitter/cyan

## examples
Expand Down
5 changes: 1 addition & 4 deletions package.json
Expand Up @@ -27,9 +27,7 @@
"example": "lerna run example",
"prebump": "yarn test",
"bump": "lerna version",
"precoverage:upload": "yarn coverage",
"coverage:upload": "codecov",
"publish:npm": "lerna publish from-git --yes --npm-tag $NPM_TAG",
"publish:npm": "lerna publish from-git --yes",
"publish:s3": "node ./scripts/publish-to-s3 apps/www/dist: apps/view/dist:view"
},
"config": {
Expand Down Expand Up @@ -89,7 +87,6 @@
"babel-loader": "^8.1.0",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"codecov": "^3.7.0",
"concat-stream": "^2.0.0",
"cross-env": "^7.0.2",
"css-loader": "^3.6.0",
Expand Down
13 changes: 8 additions & 5 deletions scripts/get-npm-tag.js
Expand Up @@ -3,18 +3,21 @@
const assert = require('assert')
const semver = require('semver')

const VERSION_REF_RE = /^refs\/tags\/(.+)$/

const argv = process.argv.slice(2)
const version = argv[0]
const ref = argv[0]
const version = typeof ref === 'string' ? ref.match(VERSION_REF_RE) : null

assert(version, 'Expected first argument to be the version')
assert(semver.valid(version), `Expected ${version} to be semver valid`)
assert(version, `Expected to be called with git tag ref, but got ${ref}`)
assert(semver.valid(version[1]), `Expected semver, but got ${version[1]}`)

const prerelease = semver.prerelease(version)
const prerelease = semver.prerelease(version[1])

if (prerelease) {
console.log(prerelease[0])
} else {
console.log('latest')
}

process.exit(0)
process.exitCode = 0

0 comments on commit 507f052

Please sign in to comment.