Skip to content

Commit b88c097

Browse files
authored
Add a workflow for easily creating releases (#4952)
I humbly present a solution our lack of releases: a workflow that can be triggered to automatically create one. This workflow builds the project, creates a GitHub release, and publishes beets to PyPi, for a one-stop solution. @sampsyo this would make it much easier to create releases, as it requires only one little interaction: going to the actions tab and entering a version number. Once that's done, the workflow should take care of the rest. I have only tested the `build` job so far, since I can't do anything about the pypi or do a release just to test, but the code is lifted from other similar actions and should work fine. It also requires one piece of setup. This is that PyPi must be set up with a [trusted publisher](https://docs.pypi.org/trusted-publishers/) to receive the new package. Once that's done, the process should go off automatically.
2 parents c75f07a + 8c898ce commit b88c097

File tree

2 files changed

+118
-228
lines changed

2 files changed

+118
-228
lines changed

.github/workflows/make_release.yaml

+91
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Make a Beets Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version of the new release'
8+
required: true
9+
10+
jobs:
11+
increment_version:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Install pandoc
16+
run: sudo apt update && sudo apt install pandoc -y
17+
- name: Set up Python
18+
uses: actions/setup-python@v4
19+
with:
20+
python-version: "3.9"
21+
- name: Run version script
22+
id: script
23+
run: |
24+
python extra/release.py "${{ inputs.version }}"
25+
- uses: EndBug/add-and-commit@v9
26+
name: Commit the changes
27+
with:
28+
message: 'Increment version numbers to ${{ inputs.version }}'
29+
30+
build:
31+
runs-on: ubuntu-latest
32+
needs: increment_version
33+
steps:
34+
- uses: actions/checkout@v4
35+
- name: Set up Python
36+
uses: actions/setup-python@v4
37+
with:
38+
python-version: "3.9"
39+
- run: pip install build wheel sphinx
40+
- name: Build a binary wheel and a source tarball
41+
env:
42+
TZ: UTC
43+
run: python3 -m build
44+
- name: Store the distribution packages
45+
uses: actions/upload-artifact@v3
46+
with:
47+
name: python-package-distributions
48+
path: dist/
49+
50+
make_github_release:
51+
runs-on: ubuntu-latest
52+
needs: build
53+
steps:
54+
- uses: actions/checkout@v4
55+
- name: Bump version and push tag
56+
id: tag_version
57+
uses: mathieudutour/[email protected]
58+
with:
59+
github_token: ${{ secrets.GITHUB_TOKEN }}
60+
custom_tag: ${{ inputs.version }}
61+
- name: Download all the dists
62+
uses: actions/download-artifact@v3
63+
with:
64+
name: python-package-distributions
65+
path: dist/
66+
- name: Create a GitHub release
67+
uses: ncipollo/release-action@v1
68+
with:
69+
tag: ${{ steps.tag_version.outputs.new_tag }}
70+
name: Release ${{ steps.tag_version.outputs.new_tag }}
71+
body: "Check [here](https://beets.readthedocs.io/en/stable/changelog.html) for the latest changes."
72+
artifacts: dist/*
73+
74+
publish_to_pypi:
75+
runs-on: ubuntu-latest
76+
needs: build
77+
environment:
78+
name: pypi
79+
url: https://pypi.org/p/beets
80+
permissions:
81+
id-token: write
82+
steps:
83+
- name: Download all the dists
84+
uses: actions/download-artifact@v3
85+
with:
86+
name: python-package-distributions
87+
path: dist/
88+
- name: Publish distribution 📦 to PyPI
89+
uses: pypa/gh-action-pypi-publish@release/v1
90+
91+

0 commit comments

Comments
 (0)