-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (84 loc) · 2.85 KB
/
Copy pathcommit.yml
File metadata and controls
99 lines (84 loc) · 2.85 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
name: build and release to pypi on commit
on:
workflow_dispatch:
push:
branches:
- "master"
jobs:
build:
name: Build
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install node
uses: actions/setup-node@v3
with:
node-version: 20
- name: Install python
uses: actions/setup-python@v4
with:
python-version: "3.12.2"
cache: "pip"
- name: ⚙️ Install dasel
run: |
curl -s -L https://github.com/TomWright/dasel/releases/download/v2.8.1/dasel_linux_amd64 > dasel
sudo mv dasel /usr/local/bin/
sudo chmod +x /usr/local/bin/dasel
dasel --version
shell: bash
- name: Install node dependencies (for versioning the release)
run: npm ci
- name: Determine new semantic version
id: determine_version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
VERSION=$(npx semantic-release --branches master --dry-run --no-ci | grep -oP "Published release \K[0-9]+\.[0-9]+\.[0-9]+")
if [[ -z "$VERSION" ]]; then
echo "No new release detected, using previous tag"
VERSION=$(git describe --tags --abbrev=0 || echo "0.0.1")
fi
echo "New version: $VERSION"
echo "version=$VERSION" >> $GITHUB_OUTPUT
- name: Update pyproject.toml with new version
run: |
echo "Setting version to ${{ steps.determine_version.outputs.version }} in pyproject.toml"
dasel put -r toml -t string -f pyproject.toml -v '${{ steps.determine_version.outputs.version }}' project.version
- name: Install python dependencies
run: |
pip install .
pip install build twine
- name: Build the package
run: python -m build
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_API_TOKEN }}
run: |
python -m twine upload dist/*
- name: Update Changelog with conventional commit messages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
npx semantic-release --branches master --no-ci --dry-run=false
- name: 📦 Create github release
uses: softprops/action-gh-release@v2
id: create_release
env:
GITHUB_TOKEN: ${{ github.token }}
with:
name: ${{ steps.determine_version.outputs.version }}
tag_name: ${{ steps.determine_version.outputs.version }}
draft: false
prerelease: false
fail_on_unmatched_files: true
body_path: CHANGELOG.md
files: |
dist/*.whl
dist/*.tar.gz