-
Notifications
You must be signed in to change notification settings - Fork 8
73 lines (67 loc) · 2.04 KB
/
release.yaml
File metadata and controls
73 lines (67 loc) · 2.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
name: Release
on:
push:
tags:
- "*/v*"
jobs:
package_name:
name: Get package name
runs-on: ubuntu-latest
outputs:
package_name: ${{ steps.split.outputs.package_name }}
steps:
- name: Get repo name
# https://stackoverflow.com/questions/73402042/github-action-expressions-split-string
env:
TAG: ${{ github.ref_name }}
id: split
run: echo "package_name=${TAG%%/*}" >> $GITHUB_OUTPUT
release:
name: Release ${{ needs.package_name.outputs.package_name }}
runs-on: ubuntu-latest
needs: package_name
environment:
name: pypi
url: https://pypi.org/p/${{ needs.package_name.outputs.package_name }}
permissions:
id-token: write
if: ${{ github.repository }} == 'stapi-spec/pystapi'
defaults:
run:
working-directory: ${{ needs.package_name.outputs.package_name }}
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
- name: Create virtual environment
run: uv venv
- name: Install build
run: uv pip install build
- name: Build
run: .venv/bin/python -m build
- uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: ${{ needs.package_name.outputs.package_name}}/dist
docker:
name: Build Docker Image
runs-on: ubuntu-latest
needs: package_name
if: ${{ needs.package_name.outputs.package_name }} == 'stapi-fastapi'
permissions:
contents: read
packages: write
id-token: write
steps:
- name: Log in to the Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and Push Docker Image
uses: docker/build-push-action@v6
with:
push: true
tags: stapi-spec/stapi-fastapi:${{ github.ref_name }}
build-args: PYTHON_VERSION='3.12'