|
| 1 | +name: Release SDK (Typescript) |
| 2 | +on: |
| 3 | + workflow_dispatch: |
| 4 | + inputs: |
| 5 | + tag: |
| 6 | + description: 'Release tag name' |
| 7 | + required: true |
| 8 | + release: |
| 9 | + types: [released, prereleased] |
| 10 | + |
| 11 | + |
| 12 | +env: |
| 13 | + # The values are extracted from the github.event context, |
| 14 | + # which is only available when the workflow gets triggered by a release event. |
| 15 | + RELEASE_VERSION: ${{ github.event.release.name }} |
| 16 | + BRANCH: ${{ github.event.release.target_commitish }} |
| 17 | + |
| 18 | + |
| 19 | +jobs: |
| 20 | + release-sdk: |
| 21 | + if: github.repository_owner == 'Apicurio' && (github.event_name == 'workflow_dispatch' || startsWith(github.event.release.tag_name, '3.')) |
| 22 | + runs-on: ubuntu-20.04 |
| 23 | + timeout-minutes: 15 |
| 24 | + env: |
| 25 | + RELEASE_TYPE: release |
| 26 | + steps: |
| 27 | + - name: Fetch Release Details |
| 28 | + if: github.event_name == 'workflow_dispatch' |
| 29 | + run: | |
| 30 | + touch release.json && curl https://api.github.com/repos/${GITHUB_REPOSITORY}/releases/tags/${{ github.event.inputs.tag }} > release.json |
| 31 | + echo "RELEASE_VERSION=$(cat release.json | jq -r '.name')" >> $GITHUB_ENV |
| 32 | + echo "BRANCH=$(cat release.json | jq -r '.target_commitish')" >> $GITHUB_ENV |
| 33 | +
|
| 34 | + - name: Download Source Code |
| 35 | + run: | |
| 36 | + git config --global user.name "apicurio-ci" |
| 37 | + git config --global user.email "apicurio.ci@gmail.com" |
| 38 | + git clone --branch $RELEASE_VERSION --single-branch https://apicurio-ci:${{ secrets.ACCESS_TOKEN }}@github.com/Apicurio/apicurio-registry.git registry |
| 39 | +
|
| 40 | + # We have faced issues in the past where a github release was created from a wrong commit |
| 41 | + # This step will ensure that the release was created from the right commit |
| 42 | + - name: Verify Project Version |
| 43 | + run: | |
| 44 | + cd registry |
| 45 | + PROJECT_VERSION=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout) |
| 46 | + if [[ $PROJECT_VERSION != $RELEASE_VERSION ]] |
| 47 | + then |
| 48 | + echo "ERROR: Project Version '${PROJECT_VERSION}' does not match with Released Version '${RELEASE_VERSION}'" |
| 49 | + exit 1 |
| 50 | + fi |
| 51 | +
|
| 52 | + - name: Setup Node |
| 53 | + uses: actions/setup-node@v3 |
| 54 | + with: |
| 55 | + node-version: 18 |
| 56 | + registry-url: 'https://registry.npmjs.org' |
| 57 | + |
| 58 | + - name: Check Node Version |
| 59 | + run: node --version |
| 60 | + |
| 61 | + # Needs special tagging to use submodules: https://stackoverflow.com/a/64705638/7898052 |
| 62 | + - name: Release Typescript SDK |
| 63 | + run: | |
| 64 | + cd registry/typescript-sdk |
| 65 | + npm install |
| 66 | + npm run generate-registry-sdk |
| 67 | + npm run build |
| 68 | +
|
| 69 | + - name: Publish to npmjs.com |
| 70 | + env: |
| 71 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 72 | + run: | |
| 73 | + cd registry/typescript-sdk |
| 74 | + npm publish --access public |
| 75 | +
|
| 76 | + - name: Google Chat Notification |
| 77 | + if: ${{ failure() }} |
| 78 | + uses: Co-qn/google-chat-notification@b9227d9daa4638c9782a5bd16c4abb86268127a1 |
| 79 | + with: |
| 80 | + name: ${{ github.job }} |
| 81 | + url: ${{ secrets.GOOGLE_CHAT_WEBHOOK }} |
| 82 | + status: ${{ job.status }} |
0 commit comments