-
Notifications
You must be signed in to change notification settings - Fork 3
115 lines (99 loc) · 3.04 KB
/
workflow.yaml
File metadata and controls
115 lines (99 loc) · 3.04 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
name: release
on:
push:
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+a[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+b[0-9]+"
- "[0-9]+.[0-9]+.[0-9]+rc[0-9]+"
env:
PACKAGE_NAME: "modelforge-finetuning"
OWNER: "ForgeOpus"
TAP_NAME: "ModelForge"
jobs:
details:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.release.outputs.new_version }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: actions/checkout@v4
- name: Extract tag and version
id: release
run: |
if [[ "${{ github.ref_type }}" == "tag" ]]; then
TAG_NAME=${GITHUB_REF#refs/tags/}
NEW_VERSION=$(echo $TAG_NAME | awk -F'-' '{print $1}')
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
echo "tag_name=$TAG_NAME" >> "$GITHUB_OUTPUT"
else
echo "No tag found"; exit 1
fi
check_pypi:
needs: details
runs-on: ubuntu-latest
steps:
- name: Check latest PyPI version
run: |
response=$(curl -s https://pypi.org/pypi/${{ env.PACKAGE_NAME }}/json || echo "{}")
latest=$(echo "$response" | jq -r '.releases | keys_unsorted | last // "0.0.0"')
echo "latest_previous_version=$latest" >> $GITHUB_ENV
- name: Compare versions
run: |
if [ "$(printf '%s\n' "$latest_previous_version" "${{ needs.details.outputs.new_version }}" | sort -rV | head -n1)" != "${{ needs.details.outputs.new_version }}" ]; then
echo "New version is not greater than $latest_previous_version" && exit 1
fi
build_package:
needs: [details, check_pypi]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Install build backend
run: pip install build
- name: Build package
run: python -m build
- name: Upload dist artifacts
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
pypi_publish:
needs: [build_package]
runs-on: ubuntu-latest
environment: release
permissions:
id-token: write
steps:
- name: Download dist
uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
github_release:
needs: [build_package, details]
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: dist
path: dist/
- name: Create GitHub Release
run: |
gh release create "${{ needs.details.outputs.tag_name }}" dist/* \
--title "${{ needs.details.outputs.tag_name }}" \
--generate-notes
env:
GH_TOKEN: ${{ github.token }}