-
-
Notifications
You must be signed in to change notification settings - Fork 28
73 lines (72 loc) · 3.42 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
name: Create & Publish a New Release
on:
workflow_dispatch:
inputs:
relVersion:
description: 'Increment `patch`, `minor`, or `major` version, or specify semver manually.'
required: true
default: 'patch'
relNotes:
description: 'General comment about this release that will appear in the commit logs and release message.'
required: false
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
# We want the full repo, so we can parse the log and update our CHANGELOG.rst
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
# install hub so we can create a GitHub release easily.
sudo apt-get update && sudo apt-get install hub
# install poetry
curl -sSL https://install.python-poetry.org | python -
echo "$HOME/.poetry/bin" >> $GITHUB_PATH && PATH="$HOME/.poetry/bin:$PATH"
poetry update # install py deps and update poetry.lock
# Configure git user.
git config user.name "github-actions" && git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Increment version
run: |
prev=$(poetry version | awk '{print $2}') # Get the previous version.
poetry version ${{ github.event.inputs.relVersion }} # Set the new version.
rel=$(poetry version | awk '{print $2}') # Get the current version.
echo -e "prev=${prev}\nrel=${rel}" >> $GITHUB_ENV # save env for later steps
- name: Generate requirements.txt
run: poetry run poetry2setup > setup.py && poetry export -f requirements.txt --output requirements.txt
- name: Black & isort
run: poetry run black . && poetry run isort .
- name: Update CHANGELOG.rst
run: |
# Create the version line.
echo -e "\nv${rel}\n========================================\n" > /tmp/release.txt
# Commits since last revision.
git log v${prev}..HEAD --oneline | grep -v "Merge branch 'master'" | sed -E 's/^\w+/-/' >> /tmp/release.txt
sed -i '3r /tmp/release.txt' CHANGELOG.rst # Insert after the 3rd line.
sed -i '1d; 3d; 2a \\n### Changes:' /tmp/release.txt # Update for use in GH release.
- name: Release notes.
if: ${{ github.event.inputs.relNotes != '' }}
env:
RELNOTES: ${{ github.event.inputs.relNotes }}
run: echo -e "$RELNOTES\n" > /tmp/relnote && sed -i '2r /tmp/relnote' /tmp/release.txt
- name: Build
run: poetry build
- name: Publish to PYPI
if: ${{ github.ref == 'refs/heads/master' }}
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: test -n "$POETRY_PYPI_TOKEN_PYPI" && poetry publish || echo "No PYPI API token available. Skipping..."
- name: Commit Changes
env:
RELNOTES: ${{ github.event.inputs.relNotes }}
run: git add . && git commit -m "v${rel}" -m "$RELNOTES" && git push
- name: Create GitHub Release
if: ${{ github.ref == 'refs/heads/master' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: hub release create -F /tmp/release.txt -a dist/mopidy_ytmusic-${rel}.tar.gz -a dist/mopidy_ytmusic-${rel}-py3-none-any.whl v${rel}