build and release #29
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 and release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| isPrerelease: | |
| description: "Select whether this is pre-release" | |
| required: true | |
| default: "false" | |
| type: choice | |
| options: | |
| - "true" | |
| - "false" | |
| permissions: | |
| contents: write | |
| env: | |
| IS_PRERELEASE: ${{ github.event.inputs.isPrerelease || false }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: recursive | |
| - name: Install UV | |
| run: | | |
| UV_VERSION=$(cat ./requirement-uv.txt | awk -F'==' '{print $2}' | tr -d ' \n') | |
| curl -LsSf https://astral.sh/uv/${UV_VERSION}/install.sh | sh | |
| - name: Record original PATH | |
| id: record_original_path | |
| run: echo "PATH_ORIGINAL=$PATH" >> $GITHUB_OUTPUT | |
| - name: Activate .venv | |
| run: | | |
| uv sync --frozen | |
| . .venv/bin/activate | |
| echo PATH=${GITHUB_WORKSPACE}/.venv/bin:$PATH >> $GITHUB_ENV | |
| - name: Run Tests | |
| run: | | |
| python3 -m pre_commit run --files zkb/**/*.py | |
| - name: Build | |
| run: | | |
| export PYTHONPATH=$(pwd) | |
| python3 scripts/multi_build.py | |
| - name: Publish Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: "multi-build" | |
| retention-days: 1 | |
| if-no-files-found: "error" | |
| - name: Deactivate .venv | |
| run: echo PATH=${{ steps.record_original_path.outputs.PATH_ORIGINAL }} | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Retrieve Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: build-artifacts | |
| path: "multi-build" | |
| - name: Install UV | |
| run: | | |
| UV_VERSION=$(cat ./requirement-uv.txt | awk -F'==' '{print $2}' | tr -d ' \n') | |
| curl -LsSf https://astral.sh/uv/${UV_VERSION}/install.sh | sh | |
| - name: Get Current Version | |
| id: version | |
| run: echo "version=$(uv run scripts/common/py/get_version.py)" >> $GITHUB_OUTPUT | |
| - name: Form Tag | |
| id: tagname | |
| run: echo "tagname=v${{ steps.version.outputs.version }}" >> $GITHUB_OUTPUT | |
| - name: Release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| draft: true | |
| skipIfReleaseExists: true | |
| tag: ${{ steps.tagname.outputs.tagname }} | |
| prerelease: ${{ env.IS_PRERELEASE }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| artifacts: "multi-build/*.zip" |