| 1 |
name: Make a Beets Release |
| 2 |
|
| 3 |
on: |
| 4 |
workflow_dispatch: |
| 5 |
inputs: |
| 6 |
version: |
| 7 |
description: 'Version of the new release, just as a number with no prepended "v"' |
| 8 |
required: true |
| 9 |
type: string |
| 10 |
|
| 11 |
env: |
| 12 |
PYTHON_VERSION: "3.10" |
| 13 |
NEW_VERSION: ${{ inputs.version }} |
| 14 |
NEW_TAG: v${{ inputs.version }} |
| 15 |
|
| 16 |
jobs: |
| 17 |
increment-version: |
| 18 |
name: Bump version, commit and create tag |
| 19 |
runs-on: ubuntu-latest |
| 20 |
steps: |
| 21 |
- name: Generate release app token |
| 22 |
id: release-token |
| 23 |
uses: actions/create-github-app-token@v2 |
| 24 |
with: |
| 25 |
app-id: ${{ vars.RELEASE_APP_ID }} |
| 26 |
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }} |
| 27 |
owner: ${{ github.repository_owner }} |
| 28 |
repositories: ${{ github.event.repository.name }} |
| 29 |
|
| 30 |
- uses: actions/checkout@v5 |
| 31 |
with: |
| 32 |
token: ${{ steps.release-token.outputs.token }} |
| 33 |
- name: Install uv |
| 34 |
uses: astral-sh/[email protected] |
| 35 |
with: |
| 36 |
python-version: ${{ env.PYTHON_VERSION }} |
| 37 |
|
| 38 |
- name: Install Python tools |
| 39 |
run: uv tool install "poethepoet>=0.26,<0.47.0" |
| 40 |
|
| 41 |
- name: Install dependencies |
| 42 |
run: poe install --group release --group docs |
| 43 |
|
| 44 |
- name: Bump project version |
| 45 |
run: | |
| 46 |
poe bump "${{ env.NEW_VERSION }}" |
| 47 |
# make sure project version is updated in the lock file as well |
| 48 |
uv lock |
| 49 |
|
| 50 |
- uses: EndBug/add-and-commit@v9 |
| 51 |
id: commit_and_tag |
| 52 |
name: Commit the changes and create tag |
| 53 |
with: |
| 54 |
message: "Increment version to ${{ env.NEW_VERSION }}" |
| 55 |
tag: "${{ env.NEW_TAG }} --force" |
| 56 |
|
| 57 |
build: |
| 58 |
name: Get changelog and build the distribution package |
| 59 |
runs-on: ubuntu-latest |
| 60 |
needs: increment-version |
| 61 |
outputs: |
| 62 |
changelog: ${{ steps.generate_changelog.outputs.changelog }} |
| 63 |
steps: |
| 64 |
- uses: actions/checkout@v5 |
| 65 |
with: |
| 66 |
ref: ${{ env.NEW_TAG }} |
| 67 |
|
| 68 |
- name: Install uv |
| 69 |
uses: astral-sh/[email protected] |
| 70 |
with: |
| 71 |
python-version: ${{ env.PYTHON_VERSION }} |
| 72 |
|
| 73 |
- name: Install Python tools |
| 74 |
run: uv tool install "poethepoet>=0.26,<0.47.0" |
| 75 |
|
| 76 |
- name: Install dependencies |
| 77 |
run: poe install --group release --group docs |
| 78 |
|
| 79 |
- name: Install pandoc |
| 80 |
run: sudo apt update && sudo apt install pandoc -y |
| 81 |
|
| 82 |
- name: Obtain the changelog |
| 83 |
id: generate_changelog |
| 84 |
run: | |
| 85 |
poe docs |
| 86 |
{ |
| 87 |
echo 'changelog<<EOF' |
| 88 |
poe --quiet changelog |
| 89 |
echo EOF |
| 90 |
} >> "$GITHUB_OUTPUT" |
| 91 |
|
| 92 |
- name: Build a binary wheel and a source tarball |
| 93 |
run: poe build |
| 94 |
|
| 95 |
- name: Store the distribution packages |
| 96 |
uses: actions/upload-artifact@v4 |
| 97 |
with: |
| 98 |
name: python-package-distributions |
| 99 |
path: dist/ |
| 100 |
|
| 101 |
publish-to-pypi: |
| 102 |
name: Publish distribution 📦 to PyPI |
| 103 |
runs-on: ubuntu-latest |
| 104 |
needs: build |
| 105 |
environment: |
| 106 |
name: pypi |
| 107 |
url: https://pypi.org/p/beets |
| 108 |
permissions: |
| 109 |
id-token: write |
| 110 |
steps: |
| 111 |
- name: Download all the dists |
| 112 |
uses: actions/download-artifact@v5 |
| 113 |
with: |
| 114 |
name: python-package-distributions |
| 115 |
path: dist/ |
| 116 |
- name: Publish distribution 📦 to PyPI |
| 117 |
uses: pypa/gh-action-pypi-publish@release/v1 |
| 118 |
|
| 119 |
make-github-release: |
| 120 |
name: Create GitHub release |
| 121 |
runs-on: ubuntu-latest |
| 122 |
needs: [build, publish-to-pypi] |
| 123 |
env: |
| 124 |
CHANGELOG: ${{ needs.build.outputs.changelog }} |
| 125 |
steps: |
| 126 |
- name: Download all the dists |
| 127 |
uses: actions/download-artifact@v5 |
| 128 |
with: |
| 129 |
name: python-package-distributions |
| 130 |
path: dist/ |
| 131 |
|
| 132 |
- name: Create a GitHub release |
| 133 |
id: make_release |
| 134 |
uses: ncipollo/release-action@v1 |
| 135 |
with: |
| 136 |
tag: ${{ env.NEW_TAG }} |
| 137 |
name: Release ${{ env.NEW_TAG }} |
| 138 |
body: ${{ env.CHANGELOG }} |
| 139 |
artifacts: dist/* |
| 140 |
- name: Send release toot to Fosstodon |
| 141 |
uses: cbrgm/mastodon-github-action@v2 |
| 142 |
continue-on-error: true |
| 143 |
with: |
| 144 |
access-token: ${{ secrets.MASTODON_ACCESS_TOKEN }} |
| 145 |
url: ${{ secrets.MASTODON_URL }} |
| 146 |
message: "Version ${{ env.NEW_TAG }} of beets has been released! Check out all of the new changes at ${{ steps.make_release.outputs.html_url }}" |