|
| 1 | +name: Build, Check, Publish |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + paths: |
| 8 | + - package.json |
| 9 | + |
| 10 | +env: |
| 11 | + NPM_REGISTRY_URL: https://registry.npmjs.org |
| 12 | + CDN_AWS_PUBLISH_ROLE: arn:aws:iam::301904545275:role/github-actions-oidc-role-prod-sign-embedded |
| 13 | + CDN_BUCKET: cdn.hellosign.com |
| 14 | + CDN_PATH: public/js/embedded |
| 15 | + AWS_REGION: us-east-1 |
| 16 | + |
| 17 | +jobs: |
| 18 | + build: |
| 19 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 20 | + runs-on: ubuntu-latest |
| 21 | + permissions: |
| 22 | + contents: read |
| 23 | + outputs: |
| 24 | + version: ${{ steps.version.outputs.version }} |
| 25 | + |
| 26 | + steps: |
| 27 | + - name: Checkout repository |
| 28 | + uses: actions/checkout@v4 |
| 29 | + |
| 30 | + - name: Use Node.js 16 for build |
| 31 | + uses: actions/setup-node@v4 |
| 32 | + with: |
| 33 | + node-version: 16.x |
| 34 | + registry-url: ${{ env.NPM_REGISTRY_URL }} |
| 35 | + |
| 36 | + - name: Build |
| 37 | + run: | |
| 38 | + npm install |
| 39 | + npm run build |
| 40 | +
|
| 41 | + - name: Test |
| 42 | + run: npm test |
| 43 | + |
| 44 | + - name: Validate Semver |
| 45 | + id: version |
| 46 | + env: |
| 47 | + GITHUB_TOKEN: ${{ github.token }} |
| 48 | + run: .github/actions-scripts/validate-release-version.js |
| 49 | + |
| 50 | + - name: Announce version |
| 51 | + run: echo "v${{ steps.version.outputs.version }} is the proposed new version." |
| 52 | + |
| 53 | + - name: Pack |
| 54 | + run: npm pack --pack-destination="./umd" |
| 55 | + |
| 56 | + - name: Upload release artifacts |
| 57 | + uses: actions/upload-artifact@v4 |
| 58 | + with: |
| 59 | + name: release-artifacts |
| 60 | + path: umd |
| 61 | + if-no-files-found: error |
| 62 | + retention-days: 1 |
| 63 | + |
| 64 | + publish: |
| 65 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 66 | + needs: build |
| 67 | + runs-on: ubuntu-latest |
| 68 | + permissions: |
| 69 | + contents: read |
| 70 | + id-token: write |
| 71 | + |
| 72 | + steps: |
| 73 | + - name: Download release artifacts |
| 74 | + uses: actions/download-artifact@v4 |
| 75 | + with: |
| 76 | + name: release-artifacts |
| 77 | + path: release-artifacts |
| 78 | + |
| 79 | + - name: Use Node.js 24 for trusted publishing |
| 80 | + uses: actions/setup-node@v4 |
| 81 | + with: |
| 82 | + node-version: 24.x |
| 83 | + registry-url: ${{ env.NPM_REGISTRY_URL }} |
| 84 | + |
| 85 | + - name: Use npm with trusted publishing support |
| 86 | + run: npm install --global npm@11.19.1 |
| 87 | + |
| 88 | + - name: Publish package with trusted publishing |
| 89 | + run: >- |
| 90 | + npm publish |
| 91 | + "./release-artifacts/hellosign-embedded-${{ needs.build.outputs.version }}.tgz" |
| 92 | + --access public |
| 93 | +
|
| 94 | + release: |
| 95 | + if: github.event_name == 'push' && github.ref == 'refs/heads/main' |
| 96 | + needs: |
| 97 | + - build |
| 98 | + - publish |
| 99 | + runs-on: ubuntu-latest |
| 100 | + permissions: |
| 101 | + contents: write |
| 102 | + id-token: write |
| 103 | + |
| 104 | + steps: |
| 105 | + - name: Download release artifacts |
| 106 | + uses: actions/download-artifact@v4 |
| 107 | + with: |
| 108 | + name: release-artifacts |
| 109 | + path: release-artifacts |
| 110 | + |
| 111 | + - name: Create GitHub release |
| 112 | + uses: actions/github-script@v7 |
| 113 | + with: |
| 114 | + script: | |
| 115 | + await github.rest.repos.createRelease({ |
| 116 | + owner: context.repo.owner, |
| 117 | + repo: context.repo.repo, |
| 118 | + tag_name: 'v${{ needs.build.outputs.version }}', |
| 119 | + }); |
| 120 | +
|
| 121 | + - name: Configure AWS credentials for production |
| 122 | + uses: aws-actions/configure-aws-credentials@v4 |
| 123 | + with: |
| 124 | + role-to-assume: ${{ env.CDN_AWS_PUBLISH_ROLE }} |
| 125 | + aws-region: ${{ env.AWS_REGION }} |
| 126 | + |
| 127 | + - name: Copy development build to production CDN |
| 128 | + run: >- |
| 129 | + aws s3 cp |
| 130 | + release-artifacts/embedded.development.js |
| 131 | + s3://${{ env.CDN_BUCKET }}/${{ env.CDN_PATH }}/v${{ needs.build.outputs.version }}/ |
| 132 | +
|
| 133 | + - name: Copy minified build to production CDN |
| 134 | + run: >- |
| 135 | + aws s3 cp |
| 136 | + release-artifacts/embedded.production.min.js |
| 137 | + s3://${{ env.CDN_BUCKET }}/${{ env.CDN_PATH }}/v${{ needs.build.outputs.version }}/ |
0 commit comments