feat: Update release (#10) #7
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: Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| id-token: write | |
| pages: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| concurrency: release | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| ssh-key: ${{ secrets.DEPLOY_KEY }} | |
| ref: ${{ github.ref_name }} | |
| fetch-depth: 0 | |
| # Required to forward SSH key to PSR Docker image | |
| - name: Setup SSH Agent with Deploy Key | |
| uses: webfactory/ssh-agent@v0.9.0 | |
| with: | |
| ssh-private-key: ${{ secrets.DEPLOY_KEY }} | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Force branch to workflow SHA | |
| run: git reset --hard ${{ github.sha }} | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.10' | |
| - name: Create virtual environment | |
| run: | | |
| python -m venv .venv | |
| source .venv/bin/activate | |
| echo "VIRTUAL_ENV=$VIRTUAL_ENV" >> $GITHUB_ENV | |
| echo "$VIRTUAL_ENV/bin" >> $GITHUB_PATH | |
| - name: Install dependencies | |
| run: | | |
| source .venv/bin/activate | |
| pip install --upgrade pip | |
| pip install python-semantic-release build wheel | |
| - name: Semantic Release | |
| id: release | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| source .venv/bin/activate | |
| semantic-release -vv version | |
| - name: Build wheel | |
| run: | | |
| source .venv/bin/activate | |
| python -m build --wheel | |
| - name: Upload to GitHub Release Assets | |
| if: steps.release.outputs.released == 'true' | |
| uses: python-semantic-release/publish-action@v10.4.1 | |
| with: | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| tag: ${{ steps.release.outputs.tag }} | |
| - name: Upload wheel artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: wheels | |
| path: dist/*.whl | |
| if-no-files-found: error | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: release | |
| if: github.event.repository.name == 'kernelfoundry' | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/project/kernelfoundry/ | |
| permissions: | |
| id-token: write # IMPORTANT: this permission is mandatory for trusted publishing | |
| steps: | |
| - name: Download wheel artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: wheels | |
| path: dist/ | |
| - name: Publish to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| deploy-pages: | |
| if: github.event_name == 'workflow_dispatch' | |
| needs: release | |
| uses: ./.github/workflows/deploy-pages.yml | |
| secrets: inherit |