-
Notifications
You must be signed in to change notification settings - Fork 73
149 lines (144 loc) · 5.53 KB
/
publish.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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Generate Client Library + Publish 📦 to npmjs + Publish to GitHub Releases
on:
workflow_dispatch:
inputs:
version:
required: true
defaults:
run:
shell: bash
permissions:
contents: read
id-token: write
env:
GENERATOR_VERSION: 3.0.54
GENERATOR_NAME: swagger-codegen-cli.jar
JAR_ASANA: codegen/swagger/target/AsanaClientCodegen-swagger-codegen-1.0.0.jar
ACTUAL_LANG: com.asana.codegen.JavascriptClientCodegenGenerator
NAME: asana
jobs:
generate-javascript-library:
name: Generate JavaScript client library
runs-on: ubuntu-latest
steps:
- name: Authenticate to AWS
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::403483446840:role/autogen_role_beta_github_actions_release_asana_client_libraries
- name: Get GitHub app token
uses: asana/get-github-app-token@v1
id: get-token
with:
github-app-name: asana-publish-client-libraries
- name: Checkout repo files and set the git token
uses: actions/checkout@v4
with:
token: ${{ steps.get-token.outputs.app-token }}
- uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: "17"
- name: Download generator
run: |
wget -q -O $GENERATOR_NAME https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/${{ env.GENERATOR_VERSION }}/swagger-codegen-cli-${{ env.GENERATOR_VERSION }}.jar
- name: Build custom code
run: |
pushd codegen/swagger >/dev/null
mvn package
popd >/dev/null
- name: Generate library
run: >-
java -cp "${{ env.JAR_ASANA }}:${{ env.GENERATOR_NAME }}"
io.swagger.codegen.v3.cli.SwaggerCodegen
generate
--input-spec https://raw.githubusercontent.com/Asana/openapi/master/defs/asana_sdk_oas.yaml
--template-dir "codegen/templates"
--lang "${{ env.ACTUAL_LANG }}"
-DpackageName=${{ env.NAME }}
--additional-properties "projectVersion=${{ inputs.version }},projectName=${{ env.NAME }},packageName=${{ env.NAME }},usePromises=true,useES6=true"
- name: Clean up generator
run: rm -rf codegen/swagger/target ${{ env.GENERATOR_NAME }}
- name: Push changes to master branch
run: |
git config user.name asana-publish-client-libraries[bot]
git config user.email 159857493+asana-publish-client-libraries[bot]@users.noreply.github.com
git add .
git commit -m 'Updated JavaScript SDK: v${{ inputs.version }}'
git push origin master
git pull
git tag 'v${{ inputs.version }}' --force
git push origin --tags --force
publish-to-npmjs:
needs: generate-javascript-library
name: Build and publish 📦 to npmjs
runs-on: ubuntu-latest
steps:
- name: Authenticate to AWS
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::403483446840:role/autogen_role_beta_github_actions_release_asana_client_libraries
- name: Load secrets
uses: aws-actions/aws-secretsmanager-get-secrets@v1
with:
secret-ids: NPM_API,prod/github_actions_release_asana_client_libraries/npm_api_key
# npm_api_key secret is stored as {key:"***..."}.
# GitHub Actions environment variable name is NPM_API so to access "key" from the json we can use NPM_API_KEY
parse-json-secrets: true
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- uses: actions/setup-node@v4
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.com"
- name: Build distribution
run: |
npm pkg set 'main'='dist/index.js'
npm pkg set 'scripts.build'='babel src -d dist'
npm pkg set 'scripts.prepare'='npm run build'
npm install
npm publish
env:
NODE_AUTH_TOKEN: ${{ env.NPM_API_KEY }}
publish-to-github-releases:
needs: publish-to-npmjs
name: Build and publish to GitHub Releases
runs-on: ubuntu-latest
steps:
- name: Authenticate to AWS
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-1
role-to-assume: arn:aws:iam::403483446840:role/autogen_role_beta_github_actions_release_asana_client_libraries
- name: Get GitHub app token
uses: asana/get-github-app-token@v1
id: get-token
with:
github-app-name: asana-publish-client-libraries
- uses: actions/checkout@v4
with:
fetch-depth: 0
ref: master
- uses: actions/setup-node@v4
with:
node-version: "18.x"
registry-url: "https://registry.npmjs.com"
- name: Build distribution
run: |
npm pkg set 'main'='dist/index.js'
npm pkg set 'scripts.build'='babel src -d dist'
npm pkg set 'scripts.prepare'='npm run build'
npm install
- name: Bundle code for browser
run: |
npm install -g browserify
npm install -g uglify-js
browserify dist/index.js -s Asana | uglifyjs > dist/asana-min.js
browserify dist/index.js -s Asana > dist/asana.js
- name: Publish to GitHub Releases
run: gh release create v${{ inputs.version }} dist/asana.js dist/asana-min.js
env:
GH_TOKEN: ${{ steps.get-token.outputs.app-token }}