-
Notifications
You must be signed in to change notification settings - Fork 20
159 lines (132 loc) · 4.98 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
# Publish package on main branch if it's tagged with 'v*'
name: Release Workflow
# Controls when the action will run.
on:
# Triggers the workflow on push events but only for the master branch
push:
tags:
- 'v*'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
permissions:
contents: write
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
UV_HTTP_TIMEOUT: 300
PIP_DISABLE_PIP_VERSION_CHECK: 1
DOCS_PY_VERSION: 3.12
jobs:
check-build:
runs-on: ubuntu-latest
outputs:
build-successful: ${{ steps.check-build-success.outputs.successful }}
run_id: ${{ steps.check-build-success.outputs.run_id }}
steps:
- name: Check latest build status
id: check-build-success
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const tagSha = context.sha;
console.log('current run sha = ' + tagSha)
dev_workflow = 'dev.yml'
const runs = await github.rest.actions.listWorkflowRuns({
owner,
repo,
workflow_id: dev_workflow,
status: 'success',
head_sha: tagSha
});
const successfulRun = runs.data.workflow_runs.find(run => run.head_sha === tagSha);
if (successfulRun) {
core.setOutput('successful', 'true');
core.setOutput('run_id', successfulRun.id);
console.log('Found Successful build run #' + successfulRun.run_number + ', run_id=' + successfulRun.id + ', it was started at ' + successfulRun.created_at)
} else {
core.setOutput('successful', 'false');
core.setFailed('No successful build for this commit/tag');
}
publish:
needs: check-build
if: ${{ needs.check-build.outputs.build-successful == 'true' }}
runs-on: ubuntu-latest
steps:
- name: Get version from tag
id: tag_name
run: |
echo ::set-output name=current_version::${GITHUB_REF#refs/tags/v}
shell: bash
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Checkout main repo
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Get Changelog Entry
id: changelog_reader
uses: mindsers/changelog-reader-action@v2
with:
version: ${{ steps.tag_name.outputs.current_version }}
path: CHANGELOG.md
- uses: actions/setup-python@v5
with:
python-version: ${{ env.DOCS_PY_VERSION }}
- name: Set up rye
run: curl -sSf https://rye.astral.sh/get | RYE_INSTALL_OPTION="--yes" bash
- name: Add Rye to PATH
run: |
echo "$HOME/.rye/env" >> $GITHUB_PATH
echo "$HOME/.rye/shims" >> $GITHUB_PATH
shell: bash
- name: Use uv instead of pip
run: rye config --set-bool behavior.use-uv=true
- name: Verify Rye Installation
run: rye --version
shell: bash
- name: Sync dependencies using rye
run: |
rye pin ${{ env.DOCS_PY_VERSION }}
rye sync --all-features
- name: Setup main repo deploy git user
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# Build docs but only alias latest for non-dev releases
- name: build documentation
run: |
git fetch origin fusion_release --depth=1
if [[ "${{ steps.tag_name.outputs.current_version }}" != *.dev* ]]; then
# Commands for regular release
rye run mike deploy --branch fusion_release --deploy-prefix docs --push --update-aliases ${{ steps.tag_name.outputs.current_version }} latest
rye run mike set-default --branch fusion_release --deploy-prefix docs --push latest
else
# Commands for pre-release
rye run mike deploy --branch fusion_release --deploy-prefix docs --push ${{ steps.tag_name.outputs.current_version }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/download-artifact@v4
with:
pattern: artifacts-*
path: dist/
merge-multiple: true
github-token: ${{ secrets.GITHUB_TOKEN }}
repository: ${{ github.repository }}
run-id: ${{ needs.check-build.outputs.run_id }}
- name: create github release
id: create_release
uses: softprops/action-gh-release@v2
with:
body: ${{ steps.changelog_reader.outputs.changes }}
files: dist/*
draft: ${{ contains(steps.tag_name.outputs.current_version, '.dev') }}
prerelease: ${{ contains(steps.tag_name.outputs.current_version, '.dev') }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: rye run twine upload dist/*