Skip to content

Commit

Permalink
Add workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
coreybutler committed Oct 9, 2020
1 parent 43abe4d commit 9eae912
Show file tree
Hide file tree
Showing 4 changed files with 227 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/FUNDING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# These are supported funding model platforms

github: [coreybutler]
90 changes: 90 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: Test Suite

on:
pull_request:
branches:
- master

jobs:
build:
name: 'Run Tests'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Checkout Code

- name: List Directory Contents (for Troubleshooting)
run: |
pwd
ls -l
- uses: actions/setup-node@v1
name: Setup Node.js
with:
node-version: '14'

- uses: actions/cache@v2
name: Establish npm Cache
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- uses: actions/cache@v2
name: Establish Docker Cache
id: cache
with:
path: docker-cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-
- name: Load cached Docker layers
run: |
if [ -d "docker-cache" ]; then
cat docker-cache/x* > my-image.tar
docker load < my-image.tar
rm -rf docker-cache
fi
- name: Download Dev Tooling
id: setup
run: |
echo ${{ secrets.GH_DOCKER_TOKEN }} | docker login https://docker.pkg.github.com -u ${{ secrets.GH_DOCKER_USER }} --password-stdin
base=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-base/tags?page_size=1'|jq '."results"[]["name"]')
base=$(sed -e 's/^"//' -e 's/"$//' <<<"$base")
echo Retrieving author/dev/dev-base:$base
docker pull author/dev-base:$base
# docker pull docker.pkg.github.com/author/dev/dev-base:$base
deno=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-deno/tags?page_size=1'|jq '."results"[]["name"]')
deno=$(sed -e 's/^"//' -e 's/"$//' <<<"$deno")
echo Retrieving author/dev/dev-deno:$deno
# docker pull docker.pkg.github.com/author/dev/dev-deno:$deno
docker pull author/dev-deno:$deno
browser=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-browser/tags?page_size=1'|jq '."results"[]["name"]')
browser=$(sed -e 's/^"//' -e 's/"$//' <<<"$browser")
echo Retrieving author/dev/dev-browser:$browser
# docker pull docker.pkg.github.com/author/dev/dev-browser:$browser
docker pull author/dev-browser:$browser
node=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-node/tags?page_size=1'|jq '."results"[]["name"]')
node=$(sed -e 's/^"//' -e 's/"$//' <<<"$node")
echo Retrieving author/dev/dev-node:$node
# docker pull docker.pkg.github.com/author/dev/dev-node:$node
docker pull author/dev-node:$node
# node -e "const p=new Set(Object.keys(require('./package.json').peerDependencies));p.delete('@author.io/dev');console.log('npm i ' + Array.from(p).join(' '))"
version=$(npm show @author.io/dev version)
echo $version
npm i -g @author.io/dev@$version
dev -v
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Test
if: success()
run: |
npm test
133 changes: 133 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
name: Test Suite

on:
push:
branches:
- master

jobs:
build:
name: 'Release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
name: Checkout Code

- uses: actions/setup-node@v1
name: Setup Node.js
with:
node-version: '14'

- uses: actions/cache@v2
name: Establish Docker Cache
id: cache
with:
path: docker-cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-
- name: Load cached Docker layers
run: |
if [ -d "docker-cache" ]; then
cat docker-cache/x* > my-image.tar
docker load < my-image.tar
rm -rf docker-cache
fi
- name: Setup Build Tooling
id: setup
run: |
base=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-base/tags?page_size=1'|jq '."results"[]["name"]')
base=$(sed -e 's/^"//' -e 's/"$//' <<<"$base")
echo Retrieving author/dev/dev-base:$base
docker pull author/dev-base:$base
deno=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-deno/tags?page_size=1'|jq '."results"[]["name"]')
deno=$(sed -e 's/^"//' -e 's/"$//' <<<"$deno")
echo Retrieving author/dev/dev-deno:$deno
docker pull author/dev-deno:$deno
browser=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-browser/tags?page_size=1'|jq '."results"[]["name"]')
browser=$(sed -e 's/^"//' -e 's/"$//' <<<"$browser")
echo Retrieving author/dev/dev-browser:$browser
docker pull author/dev-browser:$browser
node=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-node/tags?page_size=1'|jq '."results"[]["name"]')
node=$(sed -e 's/^"//' -e 's/"$//' <<<"$node")
echo Retrieving author/dev/dev-node:$node
docker pull author/dev-node:$node
# node -e "const p=new Set(Object.keys(require('./package.json').peerDependencies));p.delete('@author.io/dev');console.log('npm i ' + Array.from(p).join(' '))"
version=$(npm show @author.io/dev version)
echo $version
npm i -g @author.io/dev@$version
dev -v
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Test
if: success()
run: |
npm test
- name: Tag
id: autotagger
if: success()
uses: butlerlogic/action-autotag@stable
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"

# If the new version/tag is a pre-release (i.e. 1.0.0-beta.1), create
# an environment variable indicating it is a prerelease.
- name: Pre-release
if: steps.autotagger.outputs.tagname != ''
run: |
if [[ "${{ steps.autotagger.output.version }}" == *"-"* ]]; then echo "::set-env IS_PRERELEASE=true";else echo "::set-env IS_PRERELEASE=''";fi
- name: Release
id: create_release
if: steps.autotagger.outputs.tagname != ''
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.autotagger.outputs.tagname }}
release_name: ${{ steps.autotagger.outputs.tagname }}
body: ${{ steps.autotagger.outputs.tagmessage }}
draft: false
prerelease: env.IS_PRERELEASE != ''

# Build tarballs of the module code.
- name: Build Release Artifacts
id: build_release
if: steps.create_release.outputs.id != ''
run: |
dev build --pack
cp -rf .dist ./dist
# Upload tarballs to the release.
- name: Upload Release Artifacts
uses: AButler/[email protected]
if: steps.create_release.outputs.id != ''
with:
files: '.dist/*.tar.gz'
repo-token: ${{ secrets.GITHUB_TOKEN }}
release-tag: ${{ steps.autotagger.outputs.tagname }}

- name: Publish to npm
id: publish_npm
if: steps.autotagger.outputs.tagname != ''
uses: author/action-publish@stable
with:
scan: ./dist
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}

- name: Rollback Release
if: failure() && steps.create_release.outputs.id != ''
uses: author/action-rollback@stable
with:
tag: ${{ steps.autotagger.outputs.tagname }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ _*
!.dockerignore
!.browserslistrc
!.eslintrc
!.github
!.*.yml
package-lock.json
node_modules
Expand Down

0 comments on commit 9eae912

Please sign in to comment.