Skip to content

Commit 1f78c49

Browse files
committed
new version of release using auto, create a separate workflow for publishing (uploading to PyPI)
1 parent 0b35cb8 commit 1f78c49

File tree

2 files changed

+51
-32
lines changed

2 files changed

+51
-32
lines changed

.github/workflows/publish.yml

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# This workflows will upload a Python Package using Twine when a release is created
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries
3+
4+
name: Upload to PyPI
5+
6+
on:
7+
release:
8+
types: [published]
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
deploy:
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
- name: Set up Python
21+
uses: actions/setup-python@v5
22+
with:
23+
python-version: '^3.8'
24+
- name: Install dependencies
25+
run: |
26+
python -m pip install --upgrade pip
27+
pip install build twine
28+
29+
- name: Build and publish
30+
env:
31+
TWINE_USERNAME: __token__
32+
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
33+
run: |
34+
python -m build
35+
twine upload dist/*

.github/workflows/release.yml

+16-32
Original file line numberDiff line numberDiff line change
@@ -8,48 +8,32 @@ on:
88
jobs:
99
auto-release:
1010
runs-on: ubuntu-latest
11+
if: "!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci')"
1112
steps:
12-
- name: Checkout source
13-
uses: actions/checkout@v4
14-
with:
15-
fetch-depth: 0
13+
- uses: actions/checkout@v4
1614

17-
- name: Download auto
18-
run: |
19-
curl -vL -o - "$(curl -fsSL https://api.github.com/repos/intuit/auto/releases/latest | jq -r '.assets[] | select(.name == "auto-linux.gz") | .browser_download_url')" | gunzip > ~/auto
20-
chmod a+x ~/auto
15+
- name: Prepare repository
16+
# Fetch full git history and tags
17+
run: git fetch --unshallow --tags
2118

22-
- name: Check whether a release is due
23-
id: auto-version
24-
run: |
25-
version="$(~/auto version)"
26-
echo "version=$version" >> "$GITHUB_OUTPUT"
27-
env:
28-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19+
- name: Unset header
20+
# checkout@v2 adds a header that makes branch protection report errors
21+
# because the Github action bot is not a collaborator on the repo
22+
run: git config --local --unset http.https://github.com/.extraheader
2923

3024
- name: Set up Python
31-
if: steps.auto-version.outputs.version != ''
3225
uses: actions/setup-python@v5
3326
with:
3427
python-version: '^3.8'
3528

36-
- name: Install Python dependencies
37-
if: steps.auto-version.outputs.version != ''
38-
run: python -m pip install build twine
29+
- name: Download auto
30+
run: |
31+
auto_download_url="$(curl -fsSL https://api.github.com/repos/intuit/auto/releases/latest | jq -r '.assets[] | select(.name == "auto-linux.gz") | .browser_download_url')"
32+
wget -O- "$auto_download_url" | gunzip > ~/auto
33+
chmod a+x ~/auto
3934
4035
- name: Create release
41-
if: steps.auto-version.outputs.version != ''
42-
run: ~/auto shipit
43-
env:
44-
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45-
46-
- name: Build & upload to PyPI
47-
if: steps.auto-version.outputs.version != ''
4836
run: |
49-
python -m build
50-
twine upload dist/*
37+
~/auto shipit -vv
5138
env:
52-
TWINE_USERNAME: ${{ secrets.PYPI_USERNAME }}
53-
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
54-
55-
# vim:set sts=2:
39+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)