-
Notifications
You must be signed in to change notification settings - Fork 2
70 lines (57 loc) · 2.45 KB
/
draft-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
---
# This workflow builds the Python package and stores it as an artifact for testing during development.
# It only triggers when the 'PR Draft-Release' label is applied to a pull request.
# The built package is NOT pushed to PyPI but is instead stored in a draft GitHub release for reviewers to test.
name: Build draft release, store in GitHub repo only
on:
pull_request: {types: [opened, edited, reopened, synchronize, labeled]}
workflow_dispatch:
jobs:
build-draft-release:
runs-on: ubuntu-latest
if: github.event.label.name == 'PR Draft-Release'
strategy:
matrix:
python-version: ['3.9', '3.10', '3.11', '3.12']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
run: |-
python -m pip install --upgrade pip
pip install build wheel # Ensure both sdist and wheel are built
- name: Get version from Git tag, save to version file
run: echo $(git describe --tags --abbrev=0 | sed 's/^v//') > dist/version.txt
- name: Build package
run: python -m build # This builds both tar.gz and wheel because wheel is installed
- name: Upload builds and version file
uses: actions/upload-artifact@v3
with:
name: python-package-${{ matrix.python-version }}
path: dist/*
create-draft-release:
runs-on: ubuntu-latest
needs: build-draft-release # This job runs after all matrix jobs complete
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Download all builds and version file
uses: actions/download-artifact@v3
with:
path: dist/
- name: Read version from file
id: read_version
run: echo "VERSION=$(cat dist/version.txt)" >> $GITHUB_ENV
- name: Upload package to GitHub Release
uses: ncipollo/release-action@v1
with:
artifacts: 'dist/**' # Upload all collected artifacts
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ env.VERSION }}-pr${{ github.event.number }}
name: 'Pre-release for PR #${{ github.event.number }} - Version ${{ env.VERSION }}'
body: 'Automated pre-release build for PR #${{ github.event.number }} - Version ${{ env.VERSION }}'
draft: true # Keeps the release as draft until published