|
| 1 | +name: Release package |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + release-type: |
| 6 | + description: 'Release type (one of): patch, minor, major, prepatch, preminor, premajor, prerelease' |
| 7 | + required: true |
| 8 | +permissions: |
| 9 | + contents: write |
| 10 | +jobs: |
| 11 | + release-package: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + steps: |
| 14 | + - name: Checkout |
| 15 | + uses: actions/checkout@v4 |
| 16 | + |
| 17 | + # see also https://github.com/Nautilus-Cyberneering/pygithub |
| 18 | + - name: Import GPG key |
| 19 | + id: import-gpg |
| 20 | + uses: crazy-max/ghaction-import-gpg@v6 |
| 21 | + with: |
| 22 | + gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }} |
| 23 | + passphrase: ${{ secrets.PASSPHRASE }} |
| 24 | + git_user_signingkey: true |
| 25 | + git_commit_gpgsign: true |
| 26 | + |
| 27 | + - name: GPG user IDs |
| 28 | + run: | |
| 29 | + echo "fingerprint: ${{ steps.import-gpg.outputs.fingerprint }}" |
| 30 | + echo "keyid: ${{ steps.import-gpg.outputs.keyid }}" |
| 31 | + echo "name: ${{ steps.import-gpg.outputs.name }}" |
| 32 | + echo "email: ${{ steps.import-gpg.outputs.email }}" |
| 33 | +
|
| 34 | + - name: Setup Node.js |
| 35 | + uses: actions/setup-node@v4 |
| 36 | + with: |
| 37 | + registry-url: https://registry.npmjs.org/ |
| 38 | + node-version: '20' |
| 39 | + |
| 40 | + - name: Git configuration |
| 41 | + run: | |
| 42 | + git config --global user.email "${{ steps.import-gpg.outputs.email }}" |
| 43 | + git config --global user.name "${{ steps.import-gpg.outputs.name }}" |
| 44 | +
|
| 45 | + - name: Bump release version |
| 46 | + if: startsWith(github.event.inputs.release-type, 'pre') != true |
| 47 | + run: | |
| 48 | + echo "NEW_VERSION=$(npm --no-git-tag-version --tag-version-prefix= version $RELEASE_TYPE)" >> $GITHUB_ENV |
| 49 | + echo "RELEASE_TAG=latest" >> $GITHUB_ENV |
| 50 | + env: |
| 51 | + RELEASE_TYPE: ${{ github.event.inputs.release-type }} |
| 52 | + |
| 53 | + - name: Bump pre-release version |
| 54 | + if: startsWith(github.event.inputs.release-type, 'pre') |
| 55 | + run: | |
| 56 | + echo "NEW_VERSION=$(npm --no-git-tag-version --tag-version-prefix= --preid=beta version $RELEASE_TYPE |
| 57 | + echo "RELEASE_TAG=beta" >> $GITHUB_ENV |
| 58 | + env: |
| 59 | + RELEASE_TYPE: ${{ github.event.inputs.release-type }} |
| 60 | + |
| 61 | + - name: Update changelog |
| 62 | + uses: superfaceai/release-changelog-action@v3 |
| 63 | + with: |
| 64 | + path-to-changelog: CHANGELOG.md |
| 65 | + version: ${{ env.NEW_VERSION }} |
| 66 | + operation: release |
| 67 | + |
| 68 | + - name: Commit CHANGELOG.md and package.json changes and create tag |
| 69 | + run: | |
| 70 | + git add "package.json" |
| 71 | + git add "CHANGELOG.md" |
| 72 | + git commit -m "chore: release ${{ env.NEW_VERSION }}" |
| 73 | + git tag ${{ env.NEW_VERSION }} |
| 74 | +
|
| 75 | + - name: Build |
| 76 | + run: | |
| 77 | + yarn install --dev |
| 78 | + yarn build |
| 79 | +
|
| 80 | + - name: Publish |
| 81 | + run: yarn publish --verbose --access public --tag ${{ env.RELEASE_TAG }} |
| 82 | + env: |
| 83 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 84 | + |
| 85 | + - name: Create local package |
| 86 | + run: | |
| 87 | + yarn pack --filename "ember-nexus-web-registry-${{ env.NEW_VERSION }}.tar.gz" |
| 88 | + ls -lah |
| 89 | + pwd |
| 90 | +
|
| 91 | + - name: Push changes to repository |
| 92 | + env: |
| 93 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 94 | + run: | |
| 95 | + git push origin && git push --tags |
| 96 | +
|
| 97 | + - id: get-changelog |
| 98 | + name: Get version changelog |
| 99 | + uses: superfaceai/release-changelog-action@v3 |
| 100 | + with: |
| 101 | + path-to-changelog: CHANGELOG.md |
| 102 | + version: ${{ env.NEW_VERSION }} |
| 103 | + operation: read |
| 104 | + |
| 105 | + - name: Update GitHub release documentation |
| 106 | + uses: softprops/action-gh-release@v2 |
| 107 | + with: |
| 108 | + tag_name: ${{ env.NEW_VERSION }} |
| 109 | + body: ${{ steps.get-changelog.outputs.changelog }} |
| 110 | + prerelease: ${{ startsWith(github.event.inputs.release-type, 'pre') }} |
| 111 | + token: ${{ secrets.RELEASE_TOKEN }} |
| 112 | + files: ember-nexus-web-registry-${{ env.NEW_VERSION }}.tar.gz |
| 113 | + |
| 114 | + - name: Initiate Originstamp certificate |
| 115 | + run: | |
| 116 | + curl -X POST "http://api.originstamp.com/v4/timestamp/create" \ |
| 117 | + -H "Content-Type: application/json" \ |
| 118 | + -H "Authorization: ${{ secrets.ORIGINSTAMP_AUTH_TOKEN }}" \ |
| 119 | + -d \ |
| 120 | + "{ |
| 121 | + \"comment\": \"Release ${{ env.NEW_VERSION }} of ember-nexus/app-core\", |
| 122 | + \"hash\": \"${{ env.SHA }}\" |
| 123 | + }" |
| 124 | + env: |
| 125 | + SHA: ${{ github.sha }} |
| 126 | + |
| 127 | + - uses: JasonEtco/create-an-issue@v2 |
| 128 | + env: |
| 129 | + GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }} |
| 130 | + NEW_VERSION: ${{ env.NEW_VERSION }} |
| 131 | + with: |
| 132 | + filename: .github/ISSUE_TEMPLATE_POST_RELEASE_TASK.md |
0 commit comments