Skip to content

Commit 2ee54d9

Browse files
build: [CG-10755] combine release.yml + auto-release.yml (#403)
- **renmae steps** - **CG-10755 cmobine release yml with auto-release.yml** - **CG-10755 cmobine release yml with auto-release.yml**
1 parent e4229ba commit 2ee54d9

File tree

10 files changed

+113
-70
lines changed

10 files changed

+113
-70
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: "Release PyPI"
2+
description: "Release PyPI"
3+
inputs:
4+
pypi-token:
5+
required: true
6+
description: "PyPI token"
7+
runs:
8+
using: "composite"
9+
steps:
10+
- name: Release PyPI
11+
shell: bash
12+
run: |
13+
export UV_PUBLISH_PASSWORD="${{ inputs.pypi-token }}"
14+
export UV_PUBLISH_USERNAME="__token__"
15+
uv publish --publish-url https://upload.pypi.org/legacy/
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: "Release Slack Bot"
2+
description: "Release Slack Bot"
3+
inputs:
4+
slack-token:
5+
required: true
6+
description: "Slack token"
7+
runs:
8+
using: "composite"
9+
steps:
10+
# TODO: use python exec instead
11+
- uses: slackapi/[email protected]
12+
with:
13+
method: chat.postMessage
14+
token: ${{ inputs.slack-token }}
15+
payload: |
16+
username: ${{ job.status == 'success' && format('Released codegen@{0}', github.ref_name) || format('Failed to release codegen@{0}', github.ref_name) }}
17+
channel: "#release"
18+
icon_emoji: "${{ job.status == 'success' && ':white_check_mark:' || ':x:' }}"
19+
text: |
20+
Actor: `${{ github.triggering_actor }}`
21+
Author: `${{ github.event.head_commit.author.username }}`
22+
${{ format('Commit: <{0}/{1}/commit/{2}|{1}@{2}>', github.server_url, github.repository, github.sha) || ''}}
23+
View <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|GHA logs>

.github/actions/run_ats/action.yml renamed to .github/actions/run-ats/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ runs:
3838
run: |
3939
uv run codecovcli create-commit -t ${{ inputs.codecov_token }}
4040
uv run codecovcli create-report -t ${{ inputs.codecov_token }}
41-
bash .github/actions/run_ats/ats.sh
41+
bash .github/actions/run-ats/ats.sh
4242
4343
- name: Run tests
4444
shell: bash
File renamed without changes.

.github/workflows/auto-release.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/cache-warm-up.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
with:
2828
ref: develop # Ensure we're operating on the 'develop' branch
2929

30-
- name: Setup backend
30+
- name: Setup environment
3131
uses: ./.github/actions/setup-environment
3232

3333
warm-up-cache:
@@ -46,7 +46,7 @@ jobs:
4646
with:
4747
ref: develop # Ensure we're operating on the 'develop' branch
4848

49-
- name: Setup backend
49+
- name: Setup environment
5050
uses: ./.github/actions/setup-environment
5151

5252
- name: Cache oss-repos

.github/workflows/mypy.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
with:
2121
fetch-depth: 0
2222

23-
- name: Setup backend
23+
- name: Setup environment
2424
uses: ./.github/actions/setup-environment
2525

2626
- name: Get changed files

.github/workflows/pre-commit.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
ref: ${{ github.event.pull_request.head.ref }}
2323
token: ${{ secrets.REPO_SCOPED_TOKEN }}
2424

25-
- name: Setup backend
25+
- name: Setup environment
2626
uses: ./.github/actions/setup-environment
2727

2828
- name: Setup-pre-commit

.github/workflows/release.yml

Lines changed: 64 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,71 @@ jobs:
6969
name: wheels-${{ matrix.os }}-3.${{ matrix.python }}
7070
path: ./wheelhouse/*.whl
7171

72-
release:
73-
if: startsWith(github.ref, 'refs/tags/')
72+
auto-release:
73+
if: github.ref_name == 'develop'
74+
environment: release
7475
needs: build
7576
runs-on: ubuntu-latest
77+
permissions:
78+
checks: read # to wait for required checks
79+
contents: write # to be able to publish a GitHub release
80+
issues: write # to be able to comment on released issues
81+
pull-requests: write # to be able to comment on released pull requests
82+
steps:
83+
- uses: actions/checkout@v4
84+
with:
85+
fetch-depth: 0
86+
87+
# TODO(CG-10743): clean-up once we remove LFS
88+
- name: Remove pre-push hook
89+
run: rm -f .git/hooks/pre-push
90+
91+
- name: Setup environment
92+
uses: ./.github/actions/setup-environment
93+
94+
- name: Wait for required checks
95+
uses: poseidon/[email protected]
96+
with:
97+
token: ${{ secrets.GITHUB_TOKEN }}
98+
match_pattern: "(unit-tests|integration-tests)"
99+
100+
- name: Download All Artifacts
101+
uses: actions/download-artifact@v4
102+
with:
103+
path: dist
104+
merge-multiple: true
105+
pattern: wheels-*
106+
107+
- name: Github semantic release
108+
uses: codfish/semantic-release-action@v3
109+
id: semantic
110+
env:
111+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
112+
113+
- name: Release PyPI
114+
if: ${{ steps.semantic.outputs.new-release-published == 'true' }}
115+
uses: ./.github/actions/release-pypi
116+
with:
117+
pypi-token: ${{ secrets.PYPI_TOKEN }}
118+
119+
- name: Slack notification
120+
if: ${{ steps.semantic.outputs.new-release-published == 'true' }}
121+
uses: ./.github/actions/release-slack-bot
122+
with:
123+
release-tag: ${{ steps.semantic.outputs.release-version }}
124+
slack-token: ${{ secrets.SLACK_BOT_TOKEN }}
125+
126+
manual-release:
127+
if: startsWith(github.ref, 'refs/tags/')
76128
environment: release
129+
needs: build
130+
runs-on: ubuntu-latest
77131
permissions:
78132
contents: write # grants permission to create a release on github
79133
steps:
80134
- uses: actions/checkout@v4
81135

82-
- name: Setup backend
136+
- name: Setup environment
83137
uses: ./.github/actions/setup-environment
84138

85139
- name: Download All Artifacts
@@ -90,10 +144,9 @@ jobs:
90144
pattern: wheels-*
91145

92146
- name: Release PyPI
93-
run: |
94-
export UV_PUBLISH_PASSWORD="${{ secrets.PYPI_TOKEN }}"
95-
export UV_PUBLISH_USERNAME="__token__"
96-
uv publish --publish-url https://upload.pypi.org/legacy/
147+
uses: ./.github/actions/release-pypi
148+
with:
149+
pypi-token: ${{ secrets.PYPI_TOKEN }}
97150

98151
- name: Github release
99152
id: github-release
@@ -103,18 +156,9 @@ jobs:
103156
fail_on_unmatched_files: true
104157
generate_release_notes: true
105158

106-
# TODO: use python exec instead
107-
- uses: slackapi/[email protected]
159+
- name: Slack notification
108160
if: always()
161+
uses: ./.github/actions/release-slack-bot
109162
with:
110-
method: chat.postMessage
111-
token: ${{ secrets.SLACK_BOT_TOKEN }}
112-
payload: |
113-
username: ${{ job.status == 'success' && format('Released codegen@{0}', github.ref_name) || format('Failed to release codegen@{0}', github.ref_name) }}
114-
channel: "#release"
115-
icon_emoji: "${{ job.status == 'success' && ':white_check_mark:' || ':x:' }}"
116-
text: |
117-
Actor: `${{ github.triggering_actor }}`
118-
Author: `${{ github.event.head_commit.author.username }}`
119-
${{ format('Commit: <{0}/{1}/commit/{2}|{1}@{2}>', github.server_url, github.repository, github.sha) || ''}}
120-
View <${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|GHA logs>
163+
release-tag: ${{ github.ref_name }}
164+
slack-token: ${{ secrets.SLACK_BOT_TOKEN }}

.github/workflows/unit-tests.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
- uses: actions/checkout@v4
1818
with:
1919
fetch-depth: 0
20-
- name: Setup backend
20+
- name: Setup environment
2121
uses: ./.github/actions/setup-environment
2222
- name: Run ATS and Tests
23-
uses: ./.github/actions/run_ats
23+
uses: ./.github/actions/run-ats
2424
timeout-minutes: 15
2525
with:
2626
default_tests: "tests/unit"
@@ -48,12 +48,12 @@ jobs:
4848
name: "Codemod tests ${{matrix.size}}: Sync Graph=${{matrix.sync_graph}}"
4949
steps:
5050
- uses: actions/checkout@v4
51-
- name: Setup backend
51+
- name: Setup environment
5252
uses: ./.github/actions/setup-environment
5353
- name: Cache oss-repos
5454
uses: ./.github/actions/setup-oss-repos
5555
- name: Run ATS and Tests
56-
uses: ./.github/actions/run_ats
56+
uses: ./.github/actions/run-ats
5757
timeout-minutes: 15
5858
with:
5959
default_tests: "tests/integration/codemod/test_codemods.py"
@@ -71,7 +71,7 @@ jobs:
7171
environment: parse-tests
7272
steps:
7373
- uses: actions/checkout@v4
74-
- name: Setup backend
74+
- name: Setup environment
7575
uses: ./.github/actions/setup-environment
7676

7777
- name: Cache oss-repos
@@ -135,7 +135,7 @@ jobs:
135135
runs-on: ubuntu-latest-16
136136
steps:
137137
- uses: actions/checkout@v4
138-
- name: Setup backend
138+
- name: Setup environment
139139
uses: ./.github/actions/setup-environment
140140
- name: Test with pytest
141141
timeout-minutes: 5

0 commit comments

Comments
 (0)