-
Notifications
You must be signed in to change notification settings - Fork 2
198 lines (169 loc) · 6 KB
/
release.yaml
File metadata and controls
198 lines (169 loc) · 6 KB
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Release CodeEntropy
on:
workflow_dispatch:
inputs:
version:
required: true
default: 'x.y.z'
permissions:
contents: write
pull-requests: write
jobs:
checks:
name: Version check
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
id: repo
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.14.0
- name: Get latest release from pip
id: latestreleased
run: |
PREVIOUS_VERSION=$(python -m pip index versions CodeEntropy | grep "CodeEntropy" | cut -d "(" -f2 | cut -d ")" -f1)
echo "pip_tag=$PREVIOUS_VERSION" >> "$GITHUB_OUTPUT"
echo $PREVIOUS_VERSION
- name: version comparison
id: compare
run: |
pip3 install semver
output=$(pysemver compare ${{ steps.latestreleased.outputs.pip_tag }} ${{ github.event.inputs.version }})
if [ $output -ge 0 ]; then exit 1; fi
version:
name: prepare ${{ github.event.inputs.version }}
needs: checks
runs-on: ubuntu-24.04
steps:
- name: checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
- name: Change version in repo and CITATION.cff
run: |
# Update Python package version
sed -i "s/__version__ =.*/__version__ = \"${{ github.event.inputs.version }}\"/g" CodeEntropy/__init__.py
# Update CITATION.cff version and date-released
if [ -f CITATION.cff ]; then
sed -i -E "s/^(version:\s*).*/\1${{ github.event.inputs.version }}/" CITATION.cff
sed -i -E "s/^(date-released:\s*).*/\1'$(date -u +%F)'/" CITATION.cff
fi
- name: send PR
id: pr_id
uses: peter-evans/create-pull-request@c0f553fe549906ede9cf27b5156039d195d2ece0 # v8.1.0
with:
commit-message: Update version to ${{ github.event.inputs.version }}
branch: version-update
title: "Update to version ${{ github.event.inputs.version }}"
body: |
Update version
- Update the __init__.py with new release
- Update CITATION.cff version & date-released
- Auto-generated by [CI]
committer: version-updater <vu.bot@users.noreply.github.com>
author: version-updater <vu.bot@users.noreply.github.com>
base: main
signoff: false
draft: false
- name: auto approve review
uses: hmarr/auto-approve-action@f0939ea97e9205ef24d872e76833fa908a770363 # v4.0.0
with:
pull-request-number: ${{ steps.pr_id.outputs.pull-request-number }}
review-message: "Auto approved version bump PR"
github-token: ${{ secrets.AUTO_PR_MERGE }}
- name: merge PR
run: gh pr merge --merge --delete-branch --auto "${{ steps.pr_id.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tag:
name: tag release
needs: version
runs-on: ubuntu-24.04
steps:
- name: Checkout repository
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
with:
ref: main
- name: tag v${{ github.event.inputs.version }}
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git tag ${{ github.event.inputs.version }}
git push origin tag ${{ github.event.inputs.version }}
release:
name: make github release
needs: tag
runs-on: ubuntu-24.04
steps:
- name: create release
uses: softprops/action-gh-release@a06a81a03ee405af7f2048a818ed3f03bbf83c7b # v2.5.0
with:
name: v${{ github.event.inputs.version }}
generate_release_notes: true
tag_name: ${{ github.event.inputs.version }}
pypi:
name: make pypi release
needs: [tag, release]
runs-on: ubuntu-24.04
steps:
- name: checkout
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6
with:
ref: main
- name: Set up Python
uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0
with:
python-version: 3.14.0
- name: Install flit
run: |
python -m pip install --upgrade pip
python -m pip install flit~=3.9
- name: Build and publish
run: |
flit publish
env:
FLIT_USERNAME: __token__
FLIT_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
conda:
name: publish conda to anaconda.org
needs: [tag, release]
runs-on: ubuntu-24.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
- name: Set version in conda recipe
run: |
sed -i "s/^{% set version = \".*\" %}$/{% set version = \"${{ github.event.inputs.version }}\" %}/" conda-recipe/meta.yaml
grep '{% set version' conda-recipe/meta.yaml
- name: Setup Conda (conda-forge only)
uses: conda-incubator/setup-miniconda@v3
with:
miniforge-variant: Miniforge3
python-version: "3.12"
auto-activate: false
conda-remove-defaults: true
channels: conda-forge
channel-priority: strict
- name: Install build tools
shell: bash -l {0}
run: |
conda install -y conda-build anaconda-client
conda config --set anaconda_upload no
- name: Build package
shell: bash -l {0}
env:
PIP_NO_INDEX: "0"
run: |
PKG_PATH=$(conda build conda-recipe --output)
echo "PKG_PATH=$PKG_PATH" >> "$GITHUB_ENV"
conda build conda-recipe
test -f "$PKG_PATH"
echo "Built: $PKG_PATH"
- name: Upload to Anaconda
shell: bash -l {0}
env:
ANACONDA_API_TOKEN: ${{ secrets.ANACONDA_TOKEN }}
run: |
anaconda -t "$ANACONDA_API_TOKEN" upload "$PKG_PATH" --user CCPBioSim --force