diff --git a/.github/actions/release-pypi/action.yml b/.github/actions/release-pypi/action.yml new file mode 100644 index 000000000..94e04659d --- /dev/null +++ b/.github/actions/release-pypi/action.yml @@ -0,0 +1,15 @@ +name: "Release PyPI" +description: "Release PyPI" +inputs: + pypi-token: + required: true + description: "PyPI token" +runs: + using: "composite" + steps: + - name: Release PyPI + shell: bash + run: | + export UV_PUBLISH_PASSWORD="${{ inputs.pypi-token }}" + export UV_PUBLISH_USERNAME="__token__" + uv publish --publish-url https://upload.pypi.org/legacy/ diff --git a/.github/actions/release-slack-bot/action.yml b/.github/actions/release-slack-bot/action.yml new file mode 100644 index 000000000..3f8338372 --- /dev/null +++ b/.github/actions/release-slack-bot/action.yml @@ -0,0 +1,23 @@ +name: "Release Slack Bot" +description: "Release Slack Bot" +inputs: + slack-token: + required: true + description: "Slack token" +runs: + using: "composite" + steps: + # TODO: use python exec instead + - uses: slackapi/slack-github-action@v2.0.0 + with: + method: chat.postMessage + token: ${{ inputs.slack-token }} + payload: | + username: ${{ job.status == 'success' && format('Released codegen@{0}', github.ref_name) || format('Failed to release codegen@{0}', github.ref_name) }} + channel: "#release" + icon_emoji: "${{ job.status == 'success' && ':white_check_mark:' || ':x:' }}" + text: | + Actor: `${{ github.triggering_actor }}` + Author: `${{ github.event.head_commit.author.username }}` + ${{ format('Commit: <{0}/{1}/commit/{2}|{1}@{2}>', github.server_url, github.repository, github.sha) || ''}} + View <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|GHA logs> diff --git a/.github/actions/run_ats/action.yml b/.github/actions/run-ats/action.yml similarity index 97% rename from .github/actions/run_ats/action.yml rename to .github/actions/run-ats/action.yml index 74e04b275..f71270416 100644 --- a/.github/actions/run_ats/action.yml +++ b/.github/actions/run-ats/action.yml @@ -38,7 +38,7 @@ runs: run: | uv run codecovcli create-commit -t ${{ inputs.codecov_token }} uv run codecovcli create-report -t ${{ inputs.codecov_token }} - bash .github/actions/run_ats/ats.sh + bash .github/actions/run-ats/ats.sh - name: Run tests shell: bash diff --git a/.github/actions/run_ats/ats.sh b/.github/actions/run-ats/ats.sh similarity index 100% rename from .github/actions/run_ats/ats.sh rename to .github/actions/run-ats/ats.sh diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml deleted file mode 100644 index 4a4a9a077..000000000 --- a/.github/workflows/auto-release.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: Auto-Release -on: - push: - branches: - - develop - workflow_dispatch: - -permissions: - contents: read - -jobs: - release: - if: false # TODO(CG-10755): merge this with release.yml - name: Release - runs-on: ubuntu-latest - permissions: - checks: read # to wait for required checks - contents: write # to be able to publish a GitHub release - issues: write # to be able to comment on released issues - pull-requests: write # to be able to comment on released pull requests - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 - - # TODO(CG-10743): clean-up once we remove LFS - - name: Remove pre-push hook - run: rm -f .git/hooks/pre-push - - - name: Wait for required checks - uses: poseidon/wait-for-status-checks@v0.6.0 - with: - token: ${{ secrets.GITHUB_TOKEN }} - match_pattern: "(unit-tests|integration-tests)" - - - uses: codfish/semantic-release-action@v3 - id: semantic - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/cache-warm-up.yml b/.github/workflows/cache-warm-up.yml index ecb1af88e..1da4826df 100644 --- a/.github/workflows/cache-warm-up.yml +++ b/.github/workflows/cache-warm-up.yml @@ -27,7 +27,7 @@ jobs: with: ref: develop # Ensure we're operating on the 'develop' branch - - name: Setup backend + - name: Setup environment uses: ./.github/actions/setup-environment warm-up-cache: @@ -46,7 +46,7 @@ jobs: with: ref: develop # Ensure we're operating on the 'develop' branch - - name: Setup backend + - name: Setup environment uses: ./.github/actions/setup-environment - name: Cache oss-repos diff --git a/.github/workflows/mypy.yml b/.github/workflows/mypy.yml index 3b4654ba9..469214b8e 100644 --- a/.github/workflows/mypy.yml +++ b/.github/workflows/mypy.yml @@ -20,7 +20,7 @@ jobs: with: fetch-depth: 0 - - name: Setup backend + - name: Setup environment uses: ./.github/actions/setup-environment - name: Get changed files diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index 80de164c0..7db4079fc 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -22,7 +22,7 @@ jobs: ref: ${{ github.event.pull_request.head.ref }} token: ${{ secrets.REPO_SCOPED_TOKEN }} - - name: Setup backend + - name: Setup environment uses: ./.github/actions/setup-environment - name: Setup-pre-commit diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3c4a2b4b3..ecfcb3f67 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -69,17 +69,71 @@ jobs: name: wheels-${{ matrix.os }}-3.${{ matrix.python }} path: ./wheelhouse/*.whl - release: - if: startsWith(github.ref, 'refs/tags/') + auto-release: + if: github.ref_name == 'develop' + environment: release needs: build runs-on: ubuntu-latest + permissions: + checks: read # to wait for required checks + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + # TODO(CG-10743): clean-up once we remove LFS + - name: Remove pre-push hook + run: rm -f .git/hooks/pre-push + + - name: Setup environment + uses: ./.github/actions/setup-environment + + - name: Wait for required checks + uses: poseidon/wait-for-status-checks@v0.6.0 + with: + token: ${{ secrets.GITHUB_TOKEN }} + match_pattern: "(unit-tests|integration-tests)" + + - name: Download All Artifacts + uses: actions/download-artifact@v4 + with: + path: dist + merge-multiple: true + pattern: wheels-* + + - name: Github semantic release + uses: codfish/semantic-release-action@v3 + id: semantic + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Release PyPI + if: ${{ steps.semantic.outputs.new-release-published == 'true' }} + uses: ./.github/actions/release-pypi + with: + pypi-token: ${{ secrets.PYPI_TOKEN }} + + - name: Slack notification + if: ${{ steps.semantic.outputs.new-release-published == 'true' }} + uses: ./.github/actions/release-slack-bot + with: + release-tag: ${{ steps.semantic.outputs.release-version }} + slack-token: ${{ secrets.SLACK_BOT_TOKEN }} + + manual-release: + if: startsWith(github.ref, 'refs/tags/') environment: release + needs: build + runs-on: ubuntu-latest permissions: contents: write # grants permission to create a release on github steps: - uses: actions/checkout@v4 - - name: Setup backend + - name: Setup environment uses: ./.github/actions/setup-environment - name: Download All Artifacts @@ -90,10 +144,9 @@ jobs: pattern: wheels-* - name: Release PyPI - run: | - export UV_PUBLISH_PASSWORD="${{ secrets.PYPI_TOKEN }}" - export UV_PUBLISH_USERNAME="__token__" - uv publish --publish-url https://upload.pypi.org/legacy/ + uses: ./.github/actions/release-pypi + with: + pypi-token: ${{ secrets.PYPI_TOKEN }} - name: Github release id: github-release @@ -103,18 +156,9 @@ jobs: fail_on_unmatched_files: true generate_release_notes: true - # TODO: use python exec instead - - uses: slackapi/slack-github-action@v2.0.0 + - name: Slack notification if: always() + uses: ./.github/actions/release-slack-bot with: - method: chat.postMessage - token: ${{ secrets.SLACK_BOT_TOKEN }} - payload: | - username: ${{ job.status == 'success' && format('Released codegen@{0}', github.ref_name) || format('Failed to release codegen@{0}', github.ref_name) }} - channel: "#release" - icon_emoji: "${{ job.status == 'success' && ':white_check_mark:' || ':x:' }}" - text: | - Actor: `${{ github.triggering_actor }}` - Author: `${{ github.event.head_commit.author.username }}` - ${{ format('Commit: <{0}/{1}/commit/{2}|{1}@{2}>', github.server_url, github.repository, github.sha) || ''}} - View <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|GHA logs> + release-tag: ${{ github.ref_name }} + slack-token: ${{ secrets.SLACK_BOT_TOKEN }} diff --git a/.github/workflows/unit-tests.yml b/.github/workflows/unit-tests.yml index b4a29a187..81273392a 100644 --- a/.github/workflows/unit-tests.yml +++ b/.github/workflows/unit-tests.yml @@ -17,10 +17,10 @@ jobs: - uses: actions/checkout@v4 with: fetch-depth: 0 - - name: Setup backend + - name: Setup environment uses: ./.github/actions/setup-environment - name: Run ATS and Tests - uses: ./.github/actions/run_ats + uses: ./.github/actions/run-ats timeout-minutes: 15 with: default_tests: "tests/unit" @@ -48,12 +48,12 @@ jobs: name: "Codemod tests ${{matrix.size}}: Sync Graph=${{matrix.sync_graph}}" steps: - uses: actions/checkout@v4 - - name: Setup backend + - name: Setup environment uses: ./.github/actions/setup-environment - name: Cache oss-repos uses: ./.github/actions/setup-oss-repos - name: Run ATS and Tests - uses: ./.github/actions/run_ats + uses: ./.github/actions/run-ats timeout-minutes: 15 with: default_tests: "tests/integration/codemod/test_codemods.py" @@ -71,7 +71,7 @@ jobs: environment: parse-tests steps: - uses: actions/checkout@v4 - - name: Setup backend + - name: Setup environment uses: ./.github/actions/setup-environment - name: Cache oss-repos @@ -135,7 +135,7 @@ jobs: runs-on: ubuntu-latest-16 steps: - uses: actions/checkout@v4 - - name: Setup backend + - name: Setup environment uses: ./.github/actions/setup-environment - name: Test with pytest timeout-minutes: 5