|
| 1 | +name: Test Suite |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + |
| 8 | +jobs: |
| 9 | + build: |
| 10 | + name: 'Release' |
| 11 | + runs-on: ubuntu-latest |
| 12 | + steps: |
| 13 | + - uses: actions/checkout@v2 |
| 14 | + name: Checkout Code |
| 15 | + |
| 16 | + - uses: actions/setup-node@v1 |
| 17 | + name: Setup Node.js |
| 18 | + with: |
| 19 | + node-version: '14' |
| 20 | + |
| 21 | + - uses: actions/cache@v2 |
| 22 | + name: Establish Docker Cache |
| 23 | + id: cache |
| 24 | + with: |
| 25 | + path: docker-cache |
| 26 | + key: ${{ runner.os }}-docker-${{ github.sha }} |
| 27 | + restore-keys: | |
| 28 | + ${{ runner.os }}-docker- |
| 29 | +
|
| 30 | + - name: Load cached Docker layers |
| 31 | + run: | |
| 32 | + if [ -d "docker-cache" ]; then |
| 33 | + cat docker-cache/x* > my-image.tar |
| 34 | + docker load < my-image.tar |
| 35 | + rm -rf docker-cache |
| 36 | + fi |
| 37 | +
|
| 38 | + - name: Setup Build Tooling |
| 39 | + id: setup |
| 40 | + run: | |
| 41 | + base=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-base/tags?page_size=1'|jq '."results"[]["name"]') |
| 42 | + base=$(sed -e 's/^"//' -e 's/"$//' <<<"$base") |
| 43 | + echo Retrieving author/dev/dev-base:$base |
| 44 | + docker pull author/dev-base:$base |
| 45 | +
|
| 46 | + deno=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-deno/tags?page_size=1'|jq '."results"[]["name"]') |
| 47 | + deno=$(sed -e 's/^"//' -e 's/"$//' <<<"$deno") |
| 48 | + echo Retrieving author/dev/dev-deno:$deno |
| 49 | + docker pull author/dev-deno:$deno |
| 50 | +
|
| 51 | + browser=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-browser/tags?page_size=1'|jq '."results"[]["name"]') |
| 52 | + browser=$(sed -e 's/^"//' -e 's/"$//' <<<"$browser") |
| 53 | + echo Retrieving author/dev/dev-browser:$browser |
| 54 | + docker pull author/dev-browser:$browser |
| 55 | +
|
| 56 | + node=$(curl -L -s 'https://registry.hub.docker.com/v2/repositories/author/dev-node/tags?page_size=1'|jq '."results"[]["name"]') |
| 57 | + node=$(sed -e 's/^"//' -e 's/"$//' <<<"$node") |
| 58 | + echo Retrieving author/dev/dev-node:$node |
| 59 | + docker pull author/dev-node:$node |
| 60 | +
|
| 61 | + # 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(' '))" |
| 62 | + version=$(npm show @author.io/dev version) |
| 63 | + echo $version |
| 64 | + npm i -g @author.io/dev@$version |
| 65 | + env: |
| 66 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 67 | + |
| 68 | + - name: Test |
| 69 | + if: success() |
| 70 | + run: | |
| 71 | + dev -v |
| 72 | + npm run ci |
| 73 | +
|
| 74 | + - name: Tag |
| 75 | + id: autotagger |
| 76 | + if: success() |
| 77 | + uses: butlerlogic/action-autotag@stable |
| 78 | + with: |
| 79 | + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" |
| 80 | + |
| 81 | + # If the new version/tag is a pre-release (i.e. 1.0.0-beta.1), create |
| 82 | + # an environment variable indicating it is a prerelease. |
| 83 | + - name: Pre-release |
| 84 | + if: steps.autotagger.outputs.tagname != '' |
| 85 | + run: | |
| 86 | + if [[ "${{ steps.autotagger.output.version }}" == *"-"* ]]; then echo "::set-env IS_PRERELEASE=true";else echo "::set-env IS_PRERELEASE=''";fi |
| 87 | +
|
| 88 | + - name: Release |
| 89 | + id: create_release |
| 90 | + if: steps.autotagger.outputs.tagname != '' |
| 91 | + uses: actions/create-release@v1.0.0 |
| 92 | + env: |
| 93 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + with: |
| 95 | + tag_name: ${{ steps.autotagger.outputs.tagname }} |
| 96 | + release_name: ${{ steps.autotagger.outputs.tagname }} |
| 97 | + body: ${{ steps.autotagger.outputs.tagmessage }} |
| 98 | + draft: false |
| 99 | + prerelease: env.IS_PRERELEASE != '' |
| 100 | + |
| 101 | + # Build tarballs of the module code. |
| 102 | + - name: Build Release Artifacts |
| 103 | + id: build_release |
| 104 | + if: steps.create_release.outputs.id != '' |
| 105 | + run: | |
| 106 | + dev build --pack --mode ci --peer |
| 107 | + cp -rf .dist ./dist |
| 108 | +
|
| 109 | + # Upload tarballs to the release. |
| 110 | + - name: Upload Release Artifacts |
| 111 | + uses: AButler/upload-release-assets@v2.0 |
| 112 | + if: steps.create_release.outputs.id != '' |
| 113 | + with: |
| 114 | + files: '.dist/*.tar.gz' |
| 115 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 116 | + release-tag: ${{ steps.autotagger.outputs.tagname }} |
| 117 | + |
| 118 | + - name: Publish to npm |
| 119 | + id: publish_npm |
| 120 | + if: steps.autotagger.outputs.tagname != '' |
| 121 | + uses: author/action-publish@stable |
| 122 | + with: |
| 123 | + scan: ./dist |
| 124 | + env: |
| 125 | + REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} |
| 126 | + |
| 127 | + - name: Rollback Release |
| 128 | + if: failure() && steps.create_release.outputs.id != '' |
| 129 | + uses: author/action-rollback@stable |
| 130 | + with: |
| 131 | + tag: ${{ steps.autotagger.outputs.tagname }} |
| 132 | + env: |
| 133 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments