-
Notifications
You must be signed in to change notification settings - Fork 0
76 lines (66 loc) · 2.2 KB
/
release-and-publish.yml
File metadata and controls
76 lines (66 loc) · 2.2 KB
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
name: Release and Publish Package
on:
push:
branches:
- main
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
pull-requests: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- 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 twine python-semantic-release==10.0.2 setuptools-scm
- name: Create release branch
run: |
git config --global user.name "github-actions"
git config --global user.email "github-actions@github.com"
git checkout -b release-main
git push --set-upstream origin release-main
- name: Run semantic-release version on release-main branch
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
semantic-release --verbose version
# For semantic-release 9.x, the publish command needs to be run separately
- name: Run semantic-release publish
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#PYPI_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
run: |
semantic-release --verbose publish
- name: Push release branch
run: git push origin release-main
- name: Create PR to main
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr create \
--base main \
--head release-main \
--title "Automated Release Updates" \
--body "This pull request contains updates from the semantic-release process." || true
# This is only needed if semantic-release publish didn't handle the PyPI upload
# - name: Build and publish package to PyPI if needed
# env:
# TWINE_USERNAME: __token__
# TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
# run: |
# if [ ! -f "dist/*" ]; then
# python -m build
# twine upload dist/*
# fi