Skip to content

Commit c3be238

Browse files
build: convert release to reusable workflow (#407)
- **storing some progress** - **chore: convert release to a reusable workflow**
1 parent acf2ea4 commit c3be238

File tree

3 files changed

+67
-68
lines changed

3 files changed

+67
-68
lines changed

.github/workflows/auto-release.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Auto-Release
2+
on:
3+
push:
4+
branches:
5+
- develop
6+
workflow_dispatch:
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
semantic-version:
13+
if: false # TODO(CG-10755): merge this with release.yml
14+
name: Semantic version
15+
runs-on: ubuntu-latest
16+
outputs:
17+
tag: ${{ steps.semantic.outputs.release-version }}
18+
permissions:
19+
checks: read # to wait for required checks
20+
contents: write # to be able to publish a GitHub release
21+
issues: write # to be able to comment on released issues
22+
pull-requests: write # to be able to comment on released pull requests
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
# TODO(CG-10743): clean-up once we remove LFS
29+
- name: Remove pre-push hook
30+
run: rm -f .git/hooks/pre-push
31+
32+
- name: Wait for required checks
33+
uses: poseidon/[email protected]
34+
with:
35+
token: ${{ secrets.GITHUB_TOKEN }}
36+
match_pattern: "(unit-tests|integration-tests)"
37+
38+
- uses: codfish/semantic-release-action@v3
39+
id: semantic
40+
env:
41+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42+
43+
release:
44+
needs: semantic-version
45+
uses: ./.github/workflows/release.yml
46+
with:
47+
tag: ${{ needs.semantic-version.outputs.tag }}

.github/workflows/release.yml

Lines changed: 19 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
name: Build & Release
22

33
on:
4+
workflow_call:
5+
inputs:
6+
tag:
7+
required: true
8+
type: string
9+
description: Tag to release
10+
# TODO(CG-10758): create if it does not exist
11+
# workflow_dispatch:
12+
# inputs:
13+
# tag:
14+
# required: true
15+
# type: string
16+
# description: Tag to release # TODO: create if it does not exist
417
push:
518
tags:
619
- v*
7-
branches:
8-
- develop
920
pull_request:
1021
branches:
1122
- develop
12-
workflow_dispatch:
1323

1424
permissions:
1525
contents: read
@@ -41,7 +51,7 @@ jobs:
4151
- uses: actions/checkout@v4
4252
with:
4353
fetch-depth: 0
44-
ref: ${{ github.event.pull_request.head.ref || github.ref }}
54+
ref: ${{ inputs.tag || github.event.pull_request.head.ref || github.ref }}
4555

4656
- name: Install UV
4757
uses: astral-sh/[email protected]
@@ -69,71 +79,17 @@ jobs:
6979
name: wheels-${{ matrix.os }}-3.${{ matrix.python }}
7080
path: ./wheelhouse/*.whl
7181

72-
auto-release:
73-
if: github.ref_name == 'develop'
74-
environment: release
82+
release:
83+
if: ${{ inputs.tag || startsWith(github.ref, 'refs/tags/') }}
7584
needs: build
7685
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/')
12886
environment: release
129-
needs: build
130-
runs-on: ubuntu-latest
13187
permissions:
13288
contents: write # grants permission to create a release on github
13389
steps:
13490
- uses: actions/checkout@v4
13591

136-
- name: Setup environment
92+
- name: Setup backend
13793
uses: ./.github/actions/setup-environment
13894

13995
- name: Download All Artifacts
@@ -152,9 +108,10 @@ jobs:
152108
id: github-release
153109
uses: softprops/action-gh-release@v2
154110
with:
111+
tag_name: ${{ inputs.tag || github.ref_name }}
155112
files: dist/*
156113
fail_on_unmatched_files: true
157-
generate_release_notes: true
114+
generate_release_notes: ${{ startsWith(github.ref, 'refs/tags/') }}
158115

159116
- name: Slack notification
160117
if: always()

package.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,7 @@
55
"plugins": [
66
"@semantic-release/commit-analyzer",
77
"@semantic-release/release-notes-generator",
8-
[
9-
"@semantic-release/github",
10-
{
11-
"assets": ["dist/**"]
12-
}
13-
]
8+
"@semantic-release/github"
149
]
1510
}
1611
}

0 commit comments

Comments
 (0)