-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (86 loc) · 3 KB
/
version-release-and-publish.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
on:
workflow_dispatch: # this is required to manually run workflows; it is terribly named
inputs:
new-version:
description: The new version; e.g. '1.0.0'.
required: true
name: Version, Release, and Publish
jobs:
version:
name: Increment Version
runs-on: ubuntu-latest
permissions:
# Give the default GITHUB_TOKEN write permission to commit and push the added or changed files to the repository.
contents: write
steps:
- name: Checkout latest
uses: actions/checkout@v4
- name: Update pyproject.toml version
id: update-version
run: |
NEW_VERSION=${{ github.event.inputs.new-version }}
OLD_VERSION=$(grep 'version\s\=\s\".*\"' pyproject.toml | grep -o '"[^"]\+"' | sed 's/\"//g')
if [ "$NEW_VERSION" != "$OLD_VERSION" ]; then
sed -i "s/^version\s*=.*/version = \"$NEW_VERSION\"/" pyproject.toml
cat pyproject.toml
# uhh https://github.com/marketplace/actions/checkout#Push-a-commit-using-the-built-in-token
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git commit -m "updated pyproject.toml version"
git push
echo "VERSION=$THIS_VERSION" >> $GITHUB_OUTPUT
else
echo "The current version matches the new version: $NEW_VERSION"
exit 1
fi
create-github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
needs: version
permissions:
contents: read
steps:
# - name: Check out repository
# uses: actions/checkout@v4
- name: run ls
run: ls -la
- name: Check out latest HEAD commit
run: git checkout HEAD^
- name: Create GitHub Release
id: create_release
uses: actions/create-release@v1
env:
# This token is provided by Actions, you do not need to create your own token
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.new-version }}
release_name: v${{ github.event.inputs.new-version }}
draft: false
prerelease: false
publish-to-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
needs: create-github-release
permissions:
contents: read
steps:
# - name: Check out repository
# uses: actions/checkout@v4
- name: Check out latest HEAD commit
run: git checkout HEAD^
- name: Set up Python
uses: actions/setup-python@v3
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build
- name: Build package
run: python -m build
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1.8
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}