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