|
1 | 1 | name: Release |
2 | 2 | on: |
3 | | - push: |
| 3 | + workflow_dispatch: |
4 | 4 | branches: |
5 | 5 | - master |
6 | | - |
7 | | -permissions: |
8 | | - contents: write |
9 | | - pull-requests: write |
| 6 | + inputs: |
| 7 | + dry_run: |
| 8 | + description: 'Dry run — lint, test, and build; version bump is local only, nothing is pushed or published' |
| 9 | + required: false |
| 10 | + type: boolean |
| 11 | + default: false |
| 12 | + |
| 13 | +env: |
| 14 | + HUSKY: 0 |
10 | 15 |
|
11 | 16 | jobs: |
12 | | - # Create release PR |
13 | | - release-please: |
14 | | - name: Release Please |
| 17 | + validate: |
| 18 | + name: Lint, test & build |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v6 |
| 22 | + - uses: actions/setup-node@v6 |
| 23 | + with: |
| 24 | + node-version-file: .nvmrc |
| 25 | + cache: npm |
| 26 | + - name: Install dependencies |
| 27 | + run: npm ci |
| 28 | + - name: Lint |
| 29 | + run: npm run lint |
| 30 | + - name: Test |
| 31 | + run: npm test -- --colors --maxWorkers=2 |
| 32 | + - name: Build |
| 33 | + run: npm run build |
| 34 | + |
| 35 | + harness-macos: |
| 36 | + name: Harness tests (macOS) |
| 37 | + runs-on: macos-latest |
| 38 | + steps: |
| 39 | + - uses: maxim-lobanov/setup-xcode@v1.7.0 |
| 40 | + with: |
| 41 | + xcode-version: latest-stable |
| 42 | + - uses: actions/checkout@v6 |
| 43 | + - uses: actions/setup-node@v6 |
| 44 | + with: |
| 45 | + node-version-file: .nvmrc |
| 46 | + cache: npm |
| 47 | + - uses: actions/setup-python@v6 |
| 48 | + with: |
| 49 | + python-version: '3.12' |
| 50 | + - name: Set up Python virtual environment |
| 51 | + run: | |
| 52 | + python3 -m venv venv |
| 53 | + . venv/bin/activate |
| 54 | + pip install --upgrade pip |
| 55 | + pip install pipenv gunicorn |
| 56 | + pipenv --version |
| 57 | + gunicorn --version |
| 58 | + - run: sudo bash -c 'echo "0.0.0.0 httpbin.org" >> /etc/hosts' |
| 59 | + - run: git clone https://github.com/stoplightio/httpbin httpbin |
| 60 | + - run: | |
| 61 | + cd httpbin |
| 62 | + . ../venv/bin/activate |
| 63 | + pipenv requirements > requirements.txt |
| 64 | + pip install --no-cache-dir -r requirements.txt |
| 65 | + pip install --no-cache-dir ./ |
| 66 | + - run: | |
| 67 | + cd httpbin |
| 68 | + . ../venv/bin/activate |
| 69 | + gunicorn -b 0.0.0.0:80 httpbin:app -k gevent & |
| 70 | + sleep 15 |
| 71 | + curl -I http://0.0.0.0:80 |
| 72 | + - name: Install dependencies |
| 73 | + run: npm ci |
| 74 | + - name: Create CLI binary |
| 75 | + run: npm run build.binary |
| 76 | + - name: Run Harness |
| 77 | + run: npm run test.harness |
| 78 | + |
| 79 | + harness-docker: |
| 80 | + name: Harness tests (Docker) |
| 81 | + runs-on: ubuntu-latest |
| 82 | + steps: |
| 83 | + - uses: actions/checkout@v6 |
| 84 | + - uses: actions/setup-node@v6 |
| 85 | + with: |
| 86 | + node-version-file: .nvmrc |
| 87 | + cache: npm |
| 88 | + - name: Install Python and required packages |
| 89 | + run: | |
| 90 | + sudo apt-get update |
| 91 | + sudo apt-get install -y python3 python3-pip python3-venv |
| 92 | + - name: Set up Python virtual environment |
| 93 | + run: | |
| 94 | + python3 -m venv venv |
| 95 | + . venv/bin/activate |
| 96 | + pip install --upgrade pip |
| 97 | + pip install pipenv gunicorn |
| 98 | + pipenv --version |
| 99 | + gunicorn --version |
| 100 | + - run: sudo bash -c 'echo "0.0.0.0 httpbin.org" >> /etc/hosts' |
| 101 | + - run: git clone https://github.com/stoplightio/httpbin httpbin |
| 102 | + - run: | |
| 103 | + cd httpbin |
| 104 | + . ../venv/bin/activate |
| 105 | + pipenv requirements > requirements.txt |
| 106 | + pip3 install --no-cache-dir -r requirements.txt |
| 107 | + pip3 install --no-cache-dir ./ |
| 108 | + - run: | |
| 109 | + cd httpbin |
| 110 | + . ../venv/bin/activate |
| 111 | + sudo $(which gunicorn) -b 0.0.0.0:80 httpbin:app -k gevent & |
| 112 | + sleep 15 |
| 113 | + curl -I http://0.0.0.0:80 |
| 114 | + - name: Install dependencies |
| 115 | + run: npm ci |
| 116 | + - name: Create CLI binary |
| 117 | + run: npm run build.binary |
| 118 | + - name: Run Harness |
| 119 | + run: npm run test.harness |
| 120 | + |
| 121 | + release: |
| 122 | + name: Release |
| 123 | + runs-on: ubuntu-latest |
| 124 | + needs: [validate, harness-macos, harness-docker] |
| 125 | + steps: |
| 126 | + - name: Checkout |
| 127 | + uses: actions/checkout@v6 |
| 128 | + with: |
| 129 | + fetch-depth: 0 |
| 130 | + token: ${{ secrets.RELEASE_PLEASE_GITHUB_TOKEN }} |
| 131 | + |
| 132 | + - name: Setup Node.js |
| 133 | + uses: actions/setup-node@v6 |
| 134 | + with: |
| 135 | + node-version-file: .nvmrc |
| 136 | + registry-url: https://registry.npmjs.org |
| 137 | + cache: npm |
| 138 | + |
| 139 | + - name: Install dependencies |
| 140 | + run: npm ci |
| 141 | + |
| 142 | + - name: Build |
| 143 | + run: npm run build |
| 144 | + |
| 145 | + - name: Version bump & GitHub release |
| 146 | + run: | |
| 147 | + git config user.email "swagger-bot@smartbear.com" |
| 148 | + git config user.name "swagger-bot" |
| 149 | + npx lerna version --no-private --yes --force-publish ${{ inputs.dry_run && '--no-push' || '' }} |
| 150 | + env: |
| 151 | + GH_TOKEN: ${{ secrets.RELEASE_PLEASE_GITHUB_TOKEN }} |
| 152 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 153 | + |
| 154 | + - name: Publish npm packages |
| 155 | + if: ${{ !inputs.dry_run }} |
| 156 | + run: npx lerna publish from-package --no-private --yes |
| 157 | + env: |
| 158 | + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 159 | + |
| 160 | + sync-lockfile: |
| 161 | + name: Sync lockfile |
15 | 162 | runs-on: ubuntu-latest |
16 | | - if: github.repository == 'stoplightio/prism' |
17 | | - outputs: |
18 | | - release_created: ${{ steps.release.outputs.release_created }} |
19 | | - tag_name: ${{ steps.release.outputs.tag_name }} |
| 163 | + needs: release |
| 164 | + if: ${{ !inputs.dry_run }} |
20 | 165 | steps: |
21 | | - - name: Checkout Repository |
| 166 | + - name: Checkout |
22 | 167 | uses: actions/checkout@v6 |
23 | 168 | with: |
24 | 169 | fetch-depth: 0 |
| 170 | + token: ${{ secrets.RELEASE_PLEASE_GITHUB_TOKEN }} |
| 171 | + |
| 172 | + - name: Setup Node.js |
| 173 | + uses: actions/setup-node@v6 |
| 174 | + with: |
| 175 | + node-version-file: .nvmrc |
| 176 | + cache: npm |
| 177 | + |
| 178 | + - name: Sync lockfile |
| 179 | + run: | |
| 180 | + git config user.email "swagger-bot@smartbear.com" |
| 181 | + git config user.name "swagger-bot" |
| 182 | + git fetch origin |
| 183 | + git checkout -B master origin/master |
| 184 | + npm install |
| 185 | + git add package-lock.json |
| 186 | + git diff --cached --quiet || git commit -m "chore: sync lockfile [skip ci]" |
| 187 | + git push origin master |
25 | 188 |
|
26 | | - - uses: google-github-actions/release-please-action@v4 |
27 | | - id: release |
| 189 | + build-binaries: |
| 190 | + name: Build & publish CLI binaries |
| 191 | + runs-on: ubuntu-latest |
| 192 | + needs: release |
| 193 | + if: ${{ !inputs.dry_run }} |
| 194 | + steps: |
| 195 | + - name: Checkout |
| 196 | + uses: actions/checkout@v6 |
28 | 197 | with: |
| 198 | + fetch-depth: 0 |
29 | 199 | token: ${{ secrets.RELEASE_PLEASE_GITHUB_TOKEN }} |
30 | | - target-branch: master |
| 200 | + |
| 201 | + - name: Setup Node.js |
| 202 | + uses: actions/setup-node@v6 |
| 203 | + with: |
| 204 | + node-version-file: .nvmrc |
| 205 | + cache: npm |
| 206 | + |
| 207 | + - name: Install dependencies |
| 208 | + run: npm ci |
| 209 | + |
| 210 | + - name: Build |
| 211 | + run: npm run build |
| 212 | + |
| 213 | + - name: Create CLI binaries |
| 214 | + run: npx @yao-pkg/pkg --out-path ./cli-binaries --options max_old_space_size=4096 ./packages/cli/ |
| 215 | + |
| 216 | + - name: Upload CLI binaries artifact |
| 217 | + uses: actions/upload-artifact@v7 |
| 218 | + with: |
| 219 | + name: cli-binaries |
| 220 | + path: ./cli-binaries |
| 221 | + |
| 222 | + - name: Set up Go |
| 223 | + uses: actions/setup-go@v6 |
| 224 | + with: |
| 225 | + go-version: '1.26' |
| 226 | + |
| 227 | + - name: Download GitHub Release Utility |
| 228 | + run: go install github.com/tcnksm/ghr@latest |
| 229 | + |
| 230 | + - name: Publish Release artifacts on GitHub |
| 231 | + run: ghr -t ${{ github.token }} -u ${{ github.actor }} -r ${{ github.repository }} -c ${{ github.sha }} ${{ github.ref }} ./cli-binaries |
0 commit comments