-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (80 loc) · 2.31 KB
/
Copy pathrelease.yml
File metadata and controls
93 lines (80 loc) · 2.31 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
name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
version:
description: Existing tag to release, for example v1.0.2
required: true
type: string
permissions:
contents: write
id-token: write
jobs:
build:
name: Build distributions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.version || github.ref_name }}
- uses: actions/setup-python@v5
with:
python-version: "3.12"
- run: python -m pip install --upgrade build twine
- run: python -m build
- run: python -m twine check dist/*
- uses: actions/upload-artifact@v4
with:
name: pitstop-cli-dist
path: dist/*
publish-github:
name: Publish GitHub release
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/download-artifact@v4
with:
name: pitstop-cli-dist
path: dist
- name: Resolve release tag
run: |
if [[ "${{ github.event_name }}" == "workflow_dispatch" ]]; then
echo "VERSION=${{ inputs.version }}" >> "$GITHUB_ENV"
else
echo "VERSION=${GITHUB_REF_NAME}" >> "$GITHUB_ENV"
fi
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
run: |
if gh release view "$VERSION" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
gh release edit "$VERSION" \
--repo "$GITHUB_REPOSITORY" \
--title "$VERSION" \
--notes "Automated pitstop-cli release for $VERSION."
gh release upload "$VERSION" dist/* \
--repo "$GITHUB_REPOSITORY" \
--clobber
else
gh release create "$VERSION" dist/* \
--repo "$GITHUB_REPOSITORY" \
--title "$VERSION" \
--notes "Automated pitstop-cli release for $VERSION." \
--verify-tag
fi
publish-pypi:
name: Publish PyPI package
runs-on: ubuntu-latest
needs: build
environment: pypi
steps:
- uses: actions/download-artifact@v4
with:
name: pitstop-cli-dist
path: dist
- uses: pypa/gh-action-pypi-publish@release/v1
with:
skip-existing: true