|
1 | 1 | name: release
|
2 | 2 |
|
3 |
| -on: workflow_dispatch |
4 |
| - |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + pull_request: |
| 6 | + push: |
| 7 | + tags: |
| 8 | + - 'v[0-9].*' |
| 9 | + |
5 | 10 | env:
|
6 | 11 | GENERATOR_VERSION: 'v7.9.0'
|
| 12 | + INPUT_OPENAPI_FILE: 'openapi/openapi.yaml' |
| 13 | + GO_VERSION: '1.23' |
| 14 | + RELEASE_BRANCH: '' |
| 15 | + LATEST_COMMIT: '' |
7 | 16 |
|
8 | 17 | jobs:
|
9 | 18 | push:
|
10 | 19 | runs-on: ubuntu-latest
|
11 | 20 |
|
12 | 21 | steps:
|
| 22 | + - name: Env setup |
| 23 | + run: | |
| 24 | + git config --global user.email "[email protected]" |
| 25 | + git config --global user.name "github-actions[bot]" |
| 26 | + echo "RELEASE_BRANCH="release-"$(date +"%Y%m%d%H%M%S")" >> ${GITHUB_ENV} |
| 27 | +
|
| 28 | + - name: Install Go |
| 29 | + uses: actions/setup-go@v5 |
| 30 | + with: |
| 31 | + go-version: ${{ env.GO_VERSION }} |
| 32 | + |
13 | 33 | - name: Checkout
|
14 | 34 | uses: actions/checkout@v4
|
| 35 | + |
| 36 | + - name: Get latest commit |
| 37 | + run: | |
| 38 | + echo "LATEST_COMMIT=$(git log -1 | head -n1)" >> ${GITHUB_ENV} |
| 39 | +
|
| 40 | + - name: Generate openapi yaml definition |
| 41 | + run: | |
| 42 | + cd openapi/compose && go run compose.go && cd .. && cd .. |
| 43 | +
|
| 44 | + - name: Checkout generator templates |
| 45 | + uses: actions/checkout@v4 |
| 46 | + with: |
| 47 | + repository: OpenAPITools/openapi-generator |
| 48 | + path: official-generator-templates |
| 49 | + ref: ${{ env.GENERATOR_VERSION }} |
| 50 | + token: ${{ secrets.GH_PUSH_TOKEN }} |
| 51 | + sparse-checkout: | |
| 52 | + .github |
| 53 | + modules/openapi-generator/src/main/resources |
| 54 | +
|
| 55 | + - name: Move required templates |
| 56 | + run: | |
| 57 | + mkdir -p generated |
| 58 | + mv official-generator-templates/modules/openapi-generator/src/main/resources/go official-generator-templates/ |
| 59 | + mv official-generator-templates/modules/openapi-generator/src/main/resources/python official-generator-templates/ |
| 60 | + mv official-generator-templates/modules/openapi-generator/src/main/resources/Javascript official-generator-templates/ |
| 61 | + mv official-generator-templates/modules/openapi-generator/src/main/resources/htmlDocs2 official-generator-templates/ |
| 62 | + |
| 63 | + - name: Apply patches to templates |
| 64 | + run: | |
| 65 | + cd official-generator-templates |
| 66 | + for f in ../template-patches/*.patch; do git apply ../template-patches/${f}; done; |
| 67 | + cd .. |
| 68 | +
|
| 69 | + - name: Checkout GO client arduino repo |
| 70 | + uses: actions/checkout@v4 |
| 71 | + with: |
| 72 | + repository: arduino/iot-client-go |
| 73 | + token: ${{ secrets.GH_PUSH_TOKEN }} |
| 74 | + path: generated/go |
| 75 | + - run: | |
| 76 | + cd generated/go && git checkout -b ${{ env.RELEASE_BRANCH }} |
| 77 | +
|
| 78 | + - name: Checkout PYTHON client arduino repo |
| 79 | + uses: actions/checkout@v4 |
| 80 | + with: |
| 81 | + repository: arduino/iot-client-py |
| 82 | + token: ${{ secrets.GH_PUSH_TOKEN }} |
| 83 | + path: generated/python |
| 84 | + - run: | |
| 85 | + cd generated/python && git checkout -b ${{ env.RELEASE_BRANCH }} |
| 86 | +
|
| 87 | + - name: Checkout JAVASCRIPT client arduino repo |
| 88 | + uses: actions/checkout@v4 |
| 89 | + with: |
| 90 | + repository: arduino/iot-client-js |
| 91 | + token: ${{ secrets.GH_PUSH_TOKEN }} |
| 92 | + path: generated/javascript |
| 93 | + - run: | |
| 94 | + cd generated/javascript && git checkout -b ${{ env.RELEASE_BRANCH }} |
| 95 | +
|
| 96 | + - name: Checkout DOCS client arduino repo |
| 97 | + uses: actions/checkout@v4 |
| 98 | + with: |
| 99 | + repository: arduino/iot-client-docs |
| 100 | + token: ${{ secrets.GH_PUSH_TOKEN }} |
| 101 | + path: generated/html2 |
| 102 | + - run: | |
| 103 | + cd generated/html2 && git checkout -b ${{ env.RELEASE_BRANCH }} |
| 104 | +
|
| 105 | + - name: Generate go client |
| 106 | + uses: openapi-generators/openapitools-generator-action@v1 |
| 107 | + with: |
| 108 | + generator: go |
| 109 | + generator-tag: ${{ env.GENERATOR_VERSION }} |
| 110 | + config-file: config/languages/go_v2.json |
| 111 | + openapi-file: ${{ env.INPUT_OPENAPI_FILE }} |
| 112 | + template-dir: official-generator-templates/go/ |
| 113 | + command-args: -o generated/go |
| 114 | + |
| 115 | + - name: Generate python client |
| 116 | + uses: openapi-generators/openapitools-generator-action@v1 |
| 117 | + with: |
| 118 | + generator: python |
| 119 | + generator-tag: ${{ env.GENERATOR_VERSION }} |
| 120 | + config-file: config/languages/python_v2.json |
| 121 | + openapi-file: ${{ env.INPUT_OPENAPI_FILE }} |
| 122 | + template-dir: official-generator-templates/python/ |
| 123 | + command-args: -o generated/python |
| 124 | + |
| 125 | + - name: Generate Javascript client |
| 126 | + uses: openapi-generators/openapitools-generator-action@v1 |
| 127 | + with: |
| 128 | + generator: javascript |
| 129 | + generator-tag: ${{ env.GENERATOR_VERSION }} |
| 130 | + config-file: config/languages/javascript_v2.json |
| 131 | + openapi-file: ${{ env.INPUT_OPENAPI_FILE }} |
| 132 | + template-dir: official-generator-templates/Javascript/ |
| 133 | + command-args: -o generated/javascript |
| 134 | + |
| 135 | + - name: Generate Docs |
| 136 | + uses: openapi-generators/openapitools-generator-action@v1 |
| 137 | + with: |
| 138 | + generator: html2 |
| 139 | + generator-tag: ${{ env.GENERATOR_VERSION }} |
| 140 | + config-file: config/languages/html2_v2.json |
| 141 | + openapi-file: ${{ env.INPUT_OPENAPI_FILE }} |
| 142 | + template-dir: official-generator-templates/htmlDocs2/ |
| 143 | + command-args: -o generated/html2 |
| 144 | + |
| 145 | + - name: Apply downstream templates |
| 146 | + run: | |
| 147 | + cp downstream-templates/go/README.md generated/go/README.md |
| 148 | + cp downstream-templates/javascript/README.md generated/javascript/README.md |
| 149 | + cp downstream-templates/python/README.md generated/python/README.md |
| 150 | + cp downstream-templates/python/setup.py generated/python/setup.py |
| 151 | + cp downstream-templates/python/utils.py generated/python/iot_api_client/utils.py |
| 152 | +
|
| 153 | + - name: Copy shared assets |
| 154 | + run: | |
| 155 | + cp -R assets/shared/* generated/go/ |
| 156 | + cp -R assets/shared/* generated/python |
| 157 | + cp -R assets/shared/* generated/javascript |
| 158 | + cp -R assets/shared/* generated/html2 |
| 159 | +
|
| 160 | + - name: Open branches on external client REPOs |
| 161 | + run: | |
| 162 | + cd generated |
| 163 | + for f in $(ls -d */); do cd ${f} && git add . && git commit -m "Release ${{ env.RELEASE_BRANCH }}" && git push -u origin ${{ env.RELEASE_BRANCH }} && cd ..; done; |
| 164 | + |
| 165 | + - name: Open PRs on client REPOs |
| 166 | + run: | |
| 167 | + cd generated |
| 168 | + for f in $(ls -d */); do cd ${f} && gh pr create -B master -H ${{ env.RELEASE_BRANCH }} --title 'Regenerate clients - ${{ env.LATEST_COMMIT }}' --body 'Created by clients-iot-api clients release automation job' && cd ..; done; |
| 169 | + env: |
| 170 | + GH_TOKEN: ${{ secrets.GH_PUSH_TOKEN }} |
0 commit comments