chore: configure semantic-release for automated versioning and releas… #56
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
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| pages: write | |
| id-token: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| env: | |
| dist_artifacts_name: dist | |
| dist_artifacts_dir: dist | |
| lock_file_artifact: uv.lock | |
| steps: | |
| - name: Setup | Checkout Repository at workflow sha | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.sha }} | |
| - name: Setup | Force correct release branch on workflow sha | |
| run: git checkout -B ${{ github.ref_name }} | |
| - name: Setup | Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| enable-cache: true | |
| - name: Setup | Install Python & Project dependencies | |
| run: uv sync --all-groups | |
| - name: Build | Build next version artifacts | |
| id: version | |
| env: | |
| GH_TOKEN: "none" | |
| run: uv run semantic-release -v version --no-changelog --no-commit --no-tag | |
| - name: Upload | Distribution Artifacts | |
| if: ${{ steps.version.outputs.released == 'true' }} | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ env.dist_artifacts_name }} | |
| path: ${{ format('{0}/**', env.dist_artifacts_dir) }} | |
| if-no-files-found: error | |
| retention-days: 2 | |
| - name: Upload | Lock File Artifact | |
| if: ${{ steps.version.outputs.released == 'true' }} | |
| uses: actions/upload-artifact@v6 | |
| with: | |
| name: ${{ env.lock_file_artifact }} | |
| path: ${{ env.lock_file_artifact }} | |
| if-no-files-found: error | |
| retention-days: 2 | |
| outputs: | |
| new-release-detected: ${{ steps.version.outputs.released }} | |
| new-release-version: ${{ steps.version.outputs.version }} | |
| new-release-tag: ${{ steps.version.outputs.tag }} | |
| new-release-is-prerelease: ${{ steps.version.outputs.is_prerelease }} | |
| distribution-artifacts: ${{ env.dist_artifacts_name }} | |
| lock-file-artifact: ${{ env.lock_file_artifact }} | |
| # test-e2e: | |
| # needs: build | |
| # runs-on: ubuntu-latest | |
| # steps: | |
| # - name: Setup | Checkout Repository | |
| # uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
| # with: | |
| # ref: ${{ github.sha }} | |
| # fetch-depth: 1 | |
| # - name: Setup | Download Distribution Artifacts | |
| # uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0 | |
| # if: ${{ needs.build.outputs.new-release-detected == 'true' }} | |
| # id: artifact-download | |
| # with: | |
| # name: ${{ needs.build.outputs.distribution-artifacts }} | |
| # path: ./dist | |
| # - name: Setup | Install uv | |
| # uses: asdf-vm/actions/install@1902764435ca0dd2f3388eea723a4f92a4eb8302 # v4.0.2 | |
| # - name: Setup | Install Python & Project dependencies | |
| # run: uv sync --extra test | |
| # - name: Setup | Install distribution artifact | |
| # if: ${{ steps.artifact-download.outcome == 'success' }} | |
| # run: | | |
| # uv pip uninstall my-package | |
| # uv pip install dist/python_semantic_release-*.whl | |
| # - name: Test | Run pytest | |
| # run: uv run pytest -vv tests/e2e | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - build | |
| # - test-e2e | |
| if: ${{ needs.build.outputs.new-release-detected == 'true' }} | |
| concurrency: | |
| group: ${{ github.workflow }}-release-${{ github.ref_name }} | |
| cancel-in-progress: false | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Setup | Checkout Repository on Release Branch | |
| uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.ref_name }} | |
| - name: Setup | Force release branch to be at workflow sha | |
| run: git reset --hard ${{ github.sha }} | |
| - name: Setup | Install uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| enable-cache: true | |
| - name: Setup | Install Python & Project dependencies | |
| run: uv sync --all-groups | |
| - name: Setup | Download Build Artifacts | |
| uses: actions/download-artifact@v7 | |
| id: artifact-download | |
| with: | |
| name: ${{ needs.build.outputs.distribution-artifacts }} | |
| path: dist | |
| - name: Setup | Download Lock File Artifact | |
| uses: actions/download-artifact@v7 | |
| with: | |
| name: ${{ needs.build.outputs.lock-file-artifact }} | |
| - name: Setup | Generate commands documentation | |
| run: uv run python src/scripts/commands_to_md.py | |
| - name: Setup | Generate settings documentation | |
| run: uv run python src/scripts/settings_to_md.py | |
| - name: Setup | Stage Lock File for Version Commit | |
| run: git add uv.lock docs/ | |
| - name: Release | Create Release | |
| id: release | |
| shell: bash | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| uv run semantic-release -v --strict version --skip-build | |
| uv run semantic-release publish | |
| outputs: | |
| released: ${{ steps.release.outputs.released }} | |
| new-release-version: ${{ steps.release.outputs.version }} | |
| new-release-tag: ${{ steps.release.outputs.tag }} | |
| deploy: | |
| name: Deploy | |
| runs-on: ubuntu-latest | |
| if: ${{ needs.release.outputs.released == 'true' && github.repository == 'usethefork/byte' }} | |
| needs: | |
| - build | |
| - release | |
| environment: | |
| name: pypi | |
| url: https://pypi.org/project/byte-ai-cli/ | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Setup | Download Build Artifacts | |
| uses: actions/download-artifact@v7 | |
| id: artifact-download | |
| with: | |
| name: ${{ needs.build.outputs.distribution-artifacts }} | |
| path: dist | |
| - name: Publish package distributions to PyPI | |
| uses: pypa/gh-action-pypi-publish@release/v1 | |
| with: | |
| packages-dir: dist | |
| print-hash: true | |
| verbose: true | |
| deploy-docs: | |
| name: Deploy Documentation | |
| needs: release | |
| uses: ./.github/workflows/deploy-docs.yml |