fix(ci): trigger publish and upload_artifacts only on 'chore: release… #30
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build | ||
| on: | ||
| push: | ||
| branches: [master] | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, edited] | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: .nvmrc | ||
| cache: 'yarn' | ||
| - name: restore_cache | ||
| uses: actions/cache@v5 | ||
| with: | ||
| key: yarn-packages-${{ github.ref_name }}-${{ hashFiles('yarn.lock') }} | ||
| path: node_modules/ | ||
| restore-keys: yarn-packages-${{ github.ref_name }}- | ||
| - name: Install Dependencies | ||
| run: yarn --frozen-lockfile | ||
| - name: Lint the codebase | ||
| run: yarn lint | ||
| - name: Run tests | ||
| run: yarn test --colors --maxWorkers=2 | ||
| - name: Run build | ||
| run: yarn build | ||
| harness-macos: | ||
| runs-on: macos-latest | ||
| env: | ||
| executor: macos | ||
| install_manually: true | ||
| steps: | ||
| - uses: maxim-lobanov/setup-xcode@v1.7.0 | ||
| with: | ||
| xcode-version: latest-stable | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: .nvmrc | ||
| cache: 'yarn' | ||
| - uses: actions/setup-python@v5 | ||
| with: | ||
| python-version: '3.12' | ||
| - name: Set up Python virtual environment | ||
| run: | | ||
| python3 -m venv venv | ||
| . venv/bin/activate | ||
| pip install --upgrade pip | ||
| pip install pipenv gunicorn | ||
| pipenv --version # Verify pipenv is installed | ||
| gunicorn --version # Verify gunicorn is installed | ||
| if: env.install_manually | ||
| - run: sudo bash -c 'echo "0.0.0.0 httpbin.org" >> /etc/hosts' | ||
| if: env.install_manually | ||
| - run: git clone https://github.com/stoplightio/httpbin httpbin | ||
| if: env.install_manually | ||
| - run: | | ||
| cd httpbin | ||
| . ../venv/bin/activate | ||
| pipenv requirements > requirements.txt | ||
| pip install --no-cache-dir -r requirements.txt | ||
| pip install --no-cache-dir ./ | ||
| if: env.install_manually | ||
| - run: | | ||
| cd httpbin | ||
| . ../venv/bin/activate | ||
| gunicorn -b 0.0.0.0:80 httpbin:app -k gevent & | ||
| sleep 15 | ||
| curl -I http://0.0.0.0:80 | ||
| if: env.install_manually | ||
| - name: Install Dependencies | ||
| run: yarn --frozen-lockfile | ||
| - name: Create CLI binary | ||
| run: yarn build.binary | ||
| - name: Run Harness | ||
| run: yarn test.harness | ||
| harness-docker: | ||
| runs-on: ubuntu-latest | ||
| env: | ||
| executor: docker-harness | ||
| install_manually: true | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: .nvmrc | ||
| cache: 'yarn' | ||
| - name: Install Python and required packages | ||
| run: | | ||
| sudo apt-get update | ||
| sudo apt-get install -y python3 python3-pip python3-venv | ||
| - name: Set up Python virtual environment | ||
| run: | | ||
| python3 -m venv venv | ||
| . venv/bin/activate | ||
| pip install --upgrade pip | ||
| pip install pipenv gunicorn | ||
| pipenv --version # Verify pipenv is installed | ||
| gunicorn --version # Verify gunicorn is installed | ||
| if: env.install_manually | ||
| - run: sudo bash -c 'echo "0.0.0.0 httpbin.org" >> /etc/hosts' | ||
| if: env.install_manually | ||
| - run: git clone https://github.com/stoplightio/httpbin httpbin | ||
| if: env.install_manually | ||
| - run: | | ||
| cd httpbin | ||
| . ../venv/bin/activate | ||
| pipenv requirements > requirements.txt | ||
| pip3 install --no-cache-dir -r requirements.txt | ||
| pip3 install --no-cache-dir ./ | ||
| if: env.install_manually | ||
| - run: | | ||
| cd httpbin | ||
| . ../venv/bin/activate | ||
| sudo $(which gunicorn) -b 0.0.0.0:80 httpbin:app -k gevent & | ||
| sleep 15 | ||
| curl -I http://0.0.0.0:80 | ||
| if: env.install_manually | ||
| - name: Install Dependencies | ||
| run: yarn --frozen-lockfile | ||
| - name: Create CLI binary | ||
| run: yarn build.binary | ||
| - name: Run Harness | ||
| run: yarn test.harness | ||
| publish: | ||
| if: github.event_name == 'push' && github.event.head_commit.message == 'chore: release master' | ||
| runs-on: ubuntu-latest | ||
| needs: | ||
| - build | ||
| - harness-macos | ||
| - harness-docker | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version-file: .nvmrc | ||
| cache: 'yarn' | ||
| - name: Set git identity | ||
| run: git config user.email "circle@circleci.com" && git config user.name "circleci" | ||
| - name: Install Dependencies | ||
| run: yarn --frozen-lockfile | ||
| - name: Build all code to JavaScript | ||
| run: yarn build | ||
| - run: echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" >> ~/.npmrc | ||
| - name: Publish | ||
| run: yarn lerna publish from-git --create-release=github --yes | ||
| - name: Create CLI binaries | ||
| run: npx @yao-pkg/pkg --out-path ./cli-binaries --options max_old_space_size=4096 ./packages/cli/ | ||
| - uses: actions/upload-artifact@v7 | ||
| with: | ||
| path: "./cli-binaries" | ||
| upload_artifacts: | ||
| if: github.event_name == 'push' && github.event.head_commit.message == 'chore: release master' | ||
| runs-on: ubuntu-latest | ||
| container: | ||
| image: golang:1.23 | ||
| needs: | ||
| - publish | ||
| steps: | ||
| - uses: actions/download-artifact@v8 | ||
| with: | ||
| path: "/tmp/" | ||
| - name: Download GitHub Release Utility | ||
| run: go install github.com/tcnksm/ghr@latest | ||
| - name: Publish Release artifacts on GitHub | ||
| run: ghr -t ${{github.token}} -u ${{ github.actor }} -r ${{ github.repository }} -c ${{ github.sha }} ${{ github.ref }} /tmp/cli-binaries | ||