-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
93 lines (93 loc) · 3.34 KB
/
action.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
92
93
name: 'AutoBump-Pypi'
description: 'Bump Version, Create Tag, Build and Publish to Twine'
inputs:
githubtoken:
description: 'The GITHUB_TOKEN secret'
required: true
default: ${{ github.token }}
twinetoken:
description: 'The twine API token to use for publishing'
required: true
default: ""
repository:
description: "resposiory url for twine"
required: true
default: "https://upload.pypi.org/legacy/"
regex:
description: "the leading string before the bump tags"
required: true
default: "version: "
runs:
using: composite
steps:
- name: Set up Python 3.8
uses: actions/setup-python@v1
with:
python-version: 3.8
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install bumpver twine build
pip install build --upgrade
shell: bash
working-directory: .
- name: Get version from pull request description
id: get_version
uses: actions/github-script@v4
with:
github-token: ${{ inputs.githubtoken }}
script: |
const pullRequest = await github.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number
});
const regex = new RegExp("(?<=${{ inputs.regex }}).*", "g");
const version = pullRequest.data.body.match(regex)[0];
core.setOutput("version", version);
- name: Checkout repository
uses: actions/checkout@v2
with:
ref: main
fetch-depth: 0
- name: Bump version
run: |
echo "GITHUB_ACTOR=${{ github.actor }}" >> $GITHUB_ENV
git config user.name AutoPyPi
git config user.email "auto-pypi[bot]@users.noreply.github.com"
git checkout -b bumpversion-autopypi
if git ls-remote --exit-code --heads origin bumpversion-autopypi | grep -q bumpversion-autopypi; then
echo "Branch exists"
git pull origin bumpversion-autopypi
else
echo "Branch does not exist"
fi
git push --set-upstream origin bumpversion-autopypi
git merge --squash main
bumpver update --${{ steps.get_version.outputs.version }} --commit-message ":arrow_up: bump ${{ steps.get_version.outputs.version }} OLD → NEW" --commit
shell: bash
- name: Create pull request
if: ${{ github.event.pull_request.merged == true }}
uses: peter-evans/create-pull-request@v7
with:
title: ":arrow_up: Version bump"
commit-message: ":arrow_up: Bump Version ${{ steps.get_version.outputs.version }}"
branch: bumpversion-autopypi
base: main
body: "This pull request bumps the version of the Python package."
env:
GITHUB_TOKEN: ${{ inputs.githubtoken }}
- name: Merge Pull Requests
run: gh pr merge --merge "bumpversion-autopypi"
env:
GH_TOKEN: ${{ inputs.githubtoken }}
shell: bash
- name: Build Distribution
run: python -m build
shell: bash
- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ inputs.twinetoken }}
repository-url: ${{ inputs.repository }}
packages-dir: dist/