-
Notifications
You must be signed in to change notification settings - Fork 0
105 lines (89 loc) · 3.35 KB
/
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
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
name: Release
permissions:
contents: write
id-token: write
on:
push:
tags: "v*.*.*"
jobs:
test:
uses: ./.github/workflows/test.yml
build:
needs: test
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/asyncapi-python
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.9"
- name: Install Poetry
uses: snok/install-poetry@v1
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: Install dependencies
run: poetry install --only dev
- name: Version Check and population of PROJECT_VERSION var
run: |
PROJECT_VERSION=$(poetry version --short)
TAG=$(git describe HEAD --tags --abbrev=0)
echo "PROJECT_VERSION=$PROJECT_VERSION" >> $GITHUB_ENV
echo "Project version: $PROJECT_VERSION"
echo "Git tag: $TAG"
if [[ "$TAG" != "v$PROJECT_VERSION" ]]; then
echo "Version mismatch: Tag '$TAG' does not match project version 'v$PROJECT_VERSION'"
exit 1
fi
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
draft: true
prerelease: false
- name: Build sdist, wheel, and pex
run: >
mkdir -p dist
&& poetry export -E codegen --without dev --format requirements.txt --output dist/requirements.txt --without-hashes
&& poetry build
&& poetry run pex . --scie eager -o dist/asyncapi-python-codegen.pex -e asyncapi_python_codegen:app -r dist/requirements.txt
- name: Upload wheel to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/asyncapi_python-${{ env.PROJECT_VERSION }}-py3-none-any.whl
asset_name: asyncapi_python-${{ env.PROJECT_VERSION }}-py3-none-any.whl
asset_content_type: application/x-wheel+zip
- name: Upload sdist to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/asyncapi_python-${{ env.PROJECT_VERSION }}.tar.gz
asset_name: asyncapi_python-${{ env.PROJECT_VERSION }}.tar.gz
asset_content_type: application/gzip
- name: Upload sdist to Release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/asyncapi-python-codegen
asset_name: asyncapi-python-codegen-${{ env.PROJECT_VERSION }}.pex
asset_content_type: application/octet-stream
- name: Cleanup dist folder before PyPI publish
run: |
rm dist/asyncapi-python-codegen*
rm dist/requirements.txt
- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1