Skip to content

Commit

Permalink
Add a workflow for easily creating releases (#4952)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Serene-Arc authored May 29, 2024
2 parents c75f07a + 8c898ce commit b88c097
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 228 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/make_release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Make a Beets Release

on:
workflow_dispatch:
inputs:
version:
description: 'Version of the new release'
required: true

jobs:
increment_version:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install pandoc
run: sudo apt update && sudo apt install pandoc -y
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- name: Run version script
id: script
run: |
python extra/release.py "${{ inputs.version }}"
- uses: EndBug/add-and-commit@v9
name: Commit the changes
with:
message: 'Increment version numbers to ${{ inputs.version }}'

build:
runs-on: ubuntu-latest
needs: increment_version
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.9"
- run: pip install build wheel sphinx
- name: Build a binary wheel and a source tarball
env:
TZ: UTC
run: python3 -m build
- name: Store the distribution packages
uses: actions/upload-artifact@v3
with:
name: python-package-distributions
path: dist/

make_github_release:
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v4
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
custom_tag: ${{ inputs.version }}
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Create a GitHub release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.tag_version.outputs.new_tag }}
name: Release ${{ steps.tag_version.outputs.new_tag }}
body: "Check [here](https://beets.readthedocs.io/en/stable/changelog.html) for the latest changes."
artifacts: dist/*

publish_to_pypi:
runs-on: ubuntu-latest
needs: build
environment:
name: pypi
url: https://pypi.org/p/beets
permissions:
id-token: write
steps:
- name: Download all the dists
uses: actions/download-artifact@v3
with:
name: python-package-distributions
path: dist/
- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@release/v1


Loading

0 comments on commit b88c097

Please sign in to comment.