-
Notifications
You must be signed in to change notification settings - Fork 1
160 lines (137 loc) · 5.5 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
160
---
name: Release
on: workflow_dispatch
jobs:
build:
name: Publish a release
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.12"]
# Specifying an environment is strongly recommended by PyPI.
# See https://github.com/pypa/gh-action-pypi-publish/tree/release/v1/?tab=readme-ov-file#trusted-publishing.
environment: release
permissions:
# This is needed for PyPI publishing.
# See https://github.com/pypa/gh-action-pypi-publish/tree/release/v1/?tab=readme-ov-file#trusted-publishing.
id-token: write
# This is needed for https://github.com/stefanzweifel/git-auto-commit-action.
contents: write
steps:
- uses: actions/checkout@v4
- name: "Set up Python"
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
# We do not use the cache action as uv is faster than the cache action.
- name: "Install dependencies"
run: |
curl -LsSf https://astral.sh/uv/install.sh | sh
uv venv /home/runner/.venv
source /home/runner/.venv/bin/activate
uv pip install --upgrade --editable .[dev]
- name: "Calver calculate version"
uses: StephaneBour/actions-calver@master
id: calver
with:
date_format: "%Y.%m.%d"
release: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Update changelog"
uses: jacobtomlinson/gha-find-replace@v3
env:
NEXT_VERSION: ${{ steps.calver.outputs.release }}
with:
find: "Next\n----"
replace: "Next\n----\n\n${{ env.NEXT_VERSION }}\n------------"
include: "CHANGELOG.rst"
regex: false
- uses: stefanzweifel/git-auto-commit-action@v5
id: commit
with:
commit_message: Bump CHANGELOG
push_options: --force
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ steps.calver.outputs.release }}
tag_prefix: ""
commit_sha: ${{ steps.commit.outputs.commit_hash }}
- name: Checkout the latest tag - the one we just created
run: |
git fetch --tags
git checkout "$(git describe --tags "$(git rev-list --tags --max-count=1)")"
- name: Create Linux binaries
run: |
source /home/runner/.venv/bin/activate
PYTHONPATH=. python admin/release.py
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
artifacts: "dist/*"
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: ${{ steps.tag_version.outputs.changelog }}
- name: Build a binary wheel and a source tarball
run: |
source /home/runner/.venv/bin/activate
sudo rm -rf dist/ build/
python -m build --sdist --wheel --outdir dist/ .
# We use PyPI trusted publishing rather than a PyPI API token.
# See https://github.com/pypa/gh-action-pypi-publish/tree/release/v1/?tab=readme-ov-file#trusted-publishing.
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
verbose: true
# We have a race condition.
# In particular, we push to PyPI and then immediately try to install
# the pushed version.
# Here, we give PyPI time to propagate the package.
- name: Install VWS-CLI from PyPI
uses: nick-fields/retry@v3
env:
NEXT_VERSION: ${{ steps.calver.outputs.release }}
with:
timeout_seconds: 10
max_attempts: 20
command: pip install vws-cli==${{ env.NEXT_VERSION }}
- name: Create a Homebrew recipe
id: homebrew-create
env:
FILENAME: vws-cli.rb
run: |
source /home/runner/.venv/bin/activate
poet --formula vws-cli > ${{ env.FILENAME }}
echo "HOMEBREW_RECIPE_FILE=${{ env.FILENAME }}" >> "$GITHUB_OUTPUT"
- name: "Update Homebrew description"
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "desc \"Shiny new formula\""
replace: "desc \"CLI for Vuforia Web Services\""
include: ${{ steps.homebrew-create.outputs.HOMEBREW_RECIPE_FILE }}
regex: false
- name: "Fix Homebrew class name"
uses: jacobtomlinson/gha-find-replace@v3
with:
find: "class VWSCLI"
replace: "class VwsCli"
include: ${{ steps.homebrew-create.outputs.HOMEBREW_RECIPE_FILE }}
regex: false
- name: Push Homebrew Recipe
uses: dmnemec/copy_file_to_another_repo_action@main
env:
# See https://github.com/marketplace/actions/github-action-to-push-subdirectories-to-another-repo#usage
# for how to get this token.
# I do not yet know how to set this up to work with a
# "Fine-grained personal access token", only a "Token (classic)" with "repo" settings.
API_TOKEN_GITHUB: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
with:
destination_branch: master
source_file: ${{ steps.homebrew-create.outputs.HOMEBREW_RECIPE_FILE }}
destination_repo: 'VWS-Python/homebrew-vws'
user_email: '[email protected]'
user_name: 'adamtheturtle'
commit_message: 'Bump VWS CLI Homebrew recipe'