-
Notifications
You must be signed in to change notification settings - Fork 3
69 lines (67 loc) Β· 2.19 KB
/
build.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
name: Build
on:
push:
branches: [main]
pull_request:
permissions:
contents: write
jobs:
build:
runs-on: ubuntu-latest
outputs:
version-changed: ${{ steps.version-metadata.outputs.changed }}
new-version: ${{ steps.version-metadata.outputs.newVersion }}
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.9'
- name: Install Python build
run: pip install build
- name: Build project
run: python -m build
- name: Upload package
uses: actions/upload-artifact@v3
with:
name: artifact
path: dist/*
- name: Make sure version in pyproject.toml and pixi.toml are in sync
run: |
[ "$(yq '.project.version' pixi.toml)" = "$(yq '.project.version' pyproject.toml)" ]
- uses: Quantco/ui-actions/version-metadata@v1
id: version-metadata
with:
file: ./pixi.toml
token: ${{ secrets.GITHUB_TOKEN }}
version-extraction-override: 'regex:version = "(.*)"'
release:
name: Publish package
if: github.event_name == 'push' && github.ref_name == 'main' && needs.build.outputs.version-changed == 'true'
needs: [build]
runs-on: ubuntu-latest
permissions:
id-token: write
contents: write
environment: pypi
steps:
- uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish package on TestPyPi
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e
with:
repository-url: https://test.pypi.org/legacy/
- name: Publish package on PyPi
uses: pypa/gh-action-pypi-publish@b7f401de30cb6434a1e19f805ff006643653240e
- uses: actions/checkout@v3
- name: Push v${{ needs.build.outputs.new-version }} tag
run: |
git tag v${{ needs.build.outputs.new-version }}
git push origin v${{ needs.build.outputs.new-version }}
- name: Create release
uses: softprops/action-gh-release@v1
with:
generate_release_notes: true
tag_name: v${{ needs.build.outputs.new-version }}
draft: true