-
Notifications
You must be signed in to change notification settings - Fork 74
109 lines (107 loc) · 3.98 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
name: Generate Client Library + Publish 📦 to npmjs + Publish to GitHub Releases
on:
workflow_dispatch:
inputs:
version:
required: true
jobs:
generate-javascript-library:
name: Generate JavaScript client library
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
distribution: "temurin"
java-version: "17"
- name: Setup environment variables
run: |
echo "generator_version=3.0.52" >> "$GITHUB_ENV"
echo "generator_name=swagger-codegen-cli.jar" >> "$GITHUB_ENV"
echo "jar_asana=codegen/swagger/target/AsanaClientCodegen-swagger-codegen-1.0.0.jar" >> "$GITHUB_ENV"
echo "actual_lang=com.asana.codegen.JavascriptClientCodegenGenerator" >> "$GITHUB_ENV"
echo "name=asana" >> "$GITHUB_ENV"
- 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
uses: EndBug/add-and-commit@v9
with:
message: 'Updated JavaScript SDK: v${{ inputs.version }}'
committer_name: GitHub Actions
committer_email: [email protected]
tag: 'v${{ inputs.version }} --force'
tag_push: '--force'
build-n-publish-to-npmjs:
needs: generate-javascript-library
name: Build and publish 📦 to npmjs
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: master
- uses: actions/setup-node@v3
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: ${{ secrets.NPM_TOKEN }}
publish-to-github:
needs: build-n-publish-to-npmjs
name: Publish to GitHub Releases
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: master
- uses: actions/setup-node@v3
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
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ inputs.version }}
files: |
dist/asana.js
dist/asana-min.js