|
| 1 | +on: |
| 2 | + push: |
| 3 | + branches: |
| 4 | + - master |
| 5 | + - staging |
| 6 | + - develop |
| 7 | + |
| 8 | +name: Continuous integration |
| 9 | + |
| 10 | +jobs: |
| 11 | + build: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@v2 |
| 16 | + |
| 17 | + - name: Setup nodejs |
| 18 | + uses: actions/setup-node@v1 |
| 19 | + with: |
| 20 | + node-version: '12.x' |
| 21 | + |
| 22 | + - name: Check Release Version |
| 23 | + uses: thebongy/version-check@v1 |
| 24 | + with: |
| 25 | + file: package.json |
| 26 | + id: version_check |
| 27 | + |
| 28 | + - name: Install dependencies |
| 29 | + run: npm ci |
| 30 | + |
| 31 | + - name: Linting and Test |
| 32 | + run: npm run test:prod |
| 33 | + |
| 34 | + - name: Run Build |
| 35 | + run: npm run build |
| 36 | + |
| 37 | + - name: Create tarball |
| 38 | + run: npm pack |
| 39 | + |
| 40 | + - name: Upload Artifact |
| 41 | + uses: actions/upload-artifact@v2 |
| 42 | + with: |
| 43 | + name: juno-node-${{ steps.version_check.outputs.releaseVersion }} |
| 44 | + path: ./juno-node-${{ steps.version_check.outputs.rawVersion }}.tgz |
| 45 | + |
| 46 | + # Publish release on push to master |
| 47 | + release-master: |
| 48 | + if: github.ref == 'refs/heads/master' |
| 49 | + runs-on: ubuntu-latest |
| 50 | + needs: build |
| 51 | + steps: |
| 52 | + - uses: actions/checkout@v2 |
| 53 | + - run: git fetch --all --tags |
| 54 | + |
| 55 | + - name: Check Release Version |
| 56 | + id: version_check |
| 57 | + uses: thebongy/version-check@v1 |
| 58 | + with: |
| 59 | + file: package.json |
| 60 | + tagFormat: v${version} |
| 61 | + |
| 62 | + - name: Publish Release |
| 63 | + id: create_release |
| 64 | + uses: actions/create-release@latest |
| 65 | + with: |
| 66 | + tag_name: ${{ steps.version_check.outputs.releaseVersion }} |
| 67 | + release_name: juno-node-${{ steps.version_check.outputs.releaseVersion }} |
| 68 | + prerelease: false |
| 69 | + env: |
| 70 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 71 | + |
| 72 | + - name: Download Artifact |
| 73 | + uses: actions/download-artifact@v2 |
| 74 | + with: |
| 75 | + name: juno-node-${{ steps.version_check.outputs.releaseVersion }} |
| 76 | + |
| 77 | + - name: Upload Release Asset |
| 78 | + uses: actions/upload-release-asset@v1 |
| 79 | + env: |
| 80 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + with: |
| 82 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 83 | + asset_path: juno-node-${{ steps.version_check.outputs.rawVersion }}.tgz |
| 84 | + asset_name: juno-node-${{ steps.version_check.outputs.releaseVersion }}.tgz |
| 85 | + asset_content_type: application/tgz |
| 86 | + |
| 87 | + - name: Publish to npm |
| 88 | + run: npm publish juno-node-${{ steps.version_check.outputs.rawVersion }}.tgz |
| 89 | + env: |
| 90 | + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
| 91 | + |
| 92 | + release-staging: |
| 93 | + if: github.ref == 'refs/heads/staging' |
| 94 | + runs-on: ubuntu-latest |
| 95 | + needs: build |
| 96 | + steps: |
| 97 | + - uses: actions/checkout@v2 |
| 98 | + - run: git fetch --all --tags |
| 99 | + |
| 100 | + - name: Check Release Version |
| 101 | + id: version_check |
| 102 | + uses: thebongy/version-check@v1 |
| 103 | + with: |
| 104 | + file: package.json |
| 105 | + tagFormat: v${version}-beta |
| 106 | + |
| 107 | + - name: Download Artifact |
| 108 | + uses: actions/download-artifact@v2 |
| 109 | + with: |
| 110 | + name: juno-node-${{ steps.version_check.outputs.releaseVersion }} |
| 111 | + |
| 112 | + - name: Publish Release |
| 113 | + id: create_release |
| 114 | + uses: actions/create-release@latest |
| 115 | + with: |
| 116 | + tag_name: ${{ steps.version_check.outputs.releaseVersion }} |
| 117 | + release_name: juno-node-${{ steps.version_check.outputs.releaseVersion }} |
| 118 | + prerelease: true |
| 119 | + env: |
| 120 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 121 | + |
| 122 | + - name: Upload Release Asset |
| 123 | + uses: actions/upload-release-asset@v1 |
| 124 | + env: |
| 125 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 126 | + with: |
| 127 | + upload_url: ${{ steps.create_release.outputs.upload_url }} |
| 128 | + asset_path: juno-node-${{ steps.version_check.outputs.rawVersion }}.tgz |
| 129 | + asset_name: juno-node-${{ steps.version_check.outputs.releaseVersion }}.tgz |
| 130 | + asset_content_type: application/gzip |
| 131 | + |
| 132 | + - name: Publish to npm |
| 133 | + run: npm publish juno-node-${{ steps.version_check.outputs.rawVersion }}.tgz --tag beta |
| 134 | + env: |
| 135 | + NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} |
0 commit comments