-
Notifications
You must be signed in to change notification settings - Fork 12
143 lines (123 loc) · 4.43 KB
/
release.yaml
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
name: Release BridgeStan
on:
workflow_dispatch:
inputs:
new_version:
description: "New version, for example: 1.1.0"
required: true
is_rerun:
type: boolean
description: Set to true if this version has already been 'released', e.g. to only re-run PyPI and Julia release steps
dry_run:
type: boolean
description: Set to true to avoid PyPI and Julia release steps
default: false
jobs:
release:
name: Release BridgeStan
runs-on: ubuntu-latest
outputs:
sha: ${{ steps.commit.outputs.sha }}
steps:
- name: Check out github
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Update version numbers
if: ${{ !inputs.is_rerun }}
run: |
sed -i 's/Version:.*/Version: ${{ inputs.new_version }}/' R/DESCRIPTION
sed -i 's/version = .*/version = "${{ inputs.new_version }}"/' julia/Project.toml
sed -i 's/__version__ = .*/__version__ = "${{ inputs.new_version }}"/' python/bridgestan/__version.py
sed -i 's/^version = .*/version = "${{ inputs.new_version }}"/' rust/Cargo.toml
sed -i 's/#define BRIDGESTAN_MAJOR .*/#define BRIDGESTAN_MAJOR '"$(echo ${{ inputs.new_version }} | cut -d. -f1)"'/' src/version.hpp
sed -i 's/#define BRIDGESTAN_MINOR .*/#define BRIDGESTAN_MINOR '"$(echo ${{ inputs.new_version }} | cut -d. -f2)"'/' src/version.hpp
sed -i 's/#define BRIDGESTAN_PATCH .*/#define BRIDGESTAN_PATCH '"$(echo ${{ inputs.new_version }} | cut -d. -f3)"'/' src/version.hpp
cd docs/
python add_version.py "v${{ inputs.new_version }}"
- name: Create tarball
run: |
tar --exclude-vcs --hard-dereference -chzvf bridgestan-${{ inputs.new_version }}.tar.gz --transform 's,^,bridgestan-${{ inputs.new_version }}/,' *
- name: Setup git identity
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Create commit
id: commit
run: |
git commit -am "Release ${{ inputs.new_version }}: updating version numbers" || true
git push origin main
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
- name: Build Python package wheels
run: |
pip install wheel build
cd python/
python -m build
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: |
python/dist/*.whl
bridgestan-*.tar.gz
- name: Create release
if: ${{ !inputs.is_rerun }}
uses: ncipollo/release-action@v1
with:
artifacts: "bridgestan-*.tar.gz,python/dist/*"
tag: "v${{ inputs.new_version }}"
commit: main
draft: true
generateReleaseNotes: true
allowUpdates: true
replacesArtifacts: true
skipIfReleaseExists: true
publish:
name: Publish BridgeStan
if: ${{ !inputs.dry_run }}
runs-on: ubuntu-latest
needs: release
environment: publishing
permissions:
id-token: write
contents: write
steps:
- name: Check out github
uses: actions/checkout@v4
with:
submodules: recursive
ref: main
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: release-artifacts
- name: Publish on PyPI
uses: pypa/[email protected]
with:
packages-dir: release-artifacts/python/dist/
skip-existing: true
- name: Publish on crates.io
run: |
cd rust/
cargo publish --token ${CRATES_TOKEN}
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
- name: Create JuliaRegistration comment
if: ${{ !inputs.dry_run }}
uses: peter-evans/commit-comment@v3
with:
sha: ${{ needs.release.outputs.sha }}
body: |
@JuliaRegistrator register subdir=julia
docs:
name: Build release docs
needs: release
uses: roualdes/bridgestan/.github/workflows/docs.yaml@main
with:
version: "v${{ inputs.new_version }}"
secrets: inherit