forked from openvinotoolkit/anomalib
-
Notifications
You must be signed in to change notification settings - Fork 0
101 lines (98 loc) · 2.77 KB
/
_reusable-release-publisher.yaml
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
# Release Publisher Workflow
#
# This reusable workflow handles package publication to PyPI and GitHub,
# supporting both production and pre-release deployments.
#
# Key Features:
# - PyPI package publishing
# - GitHub release creation
# - Pre-release support
# - Release notes generation
# - Artifact management
#
# Process Stages:
# 1. Artifact Processing:
# - Download validation
# - Package verification
# - Distribution preparation
#
# 2. PyPI Publication:
# - Environment selection
# - Package upload
# - Publication verification
#
# 3. GitHub Release:
# - Release creation
# - Asset attachment
# - Notes generation
#
# Required Inputs:
# - version: Version to release
# - artifact-name: Name of artifact to publish
# - is-prerelease: Whether this is a pre-release
#
# Required Secrets:
# - pypi-token: Production PyPI token
# - test-pypi-token: Test PyPI token (for pre-releases)
#
# Example Usage:
# 1. Production Release:
# jobs:
# publish:
# uses: ./.github/workflows/_reusable-release-publisher.yaml
# with:
# version: "v1.0.0"
# artifact-name: "dist-123456789"
# is-prerelease: false
# secrets:
# pypi-token: ${{ secrets.PYPI_TOKEN }}
#
# Note: Requires appropriate tokens and permissions for publishing
name: Reusable Release Publisher
on:
workflow_call:
inputs:
version:
description: "Version to release"
required: true
type: string
artifact-name:
description: "Name of the artifact to publish"
required: true
type: string
is-prerelease:
description: "Whether this is a pre-release"
type: boolean
default: false
secrets:
pypi-token:
required: true
description: "PyPI token for package publishing"
test-pypi-token:
required: false
description: "Test PyPI token for pre-releases"
jobs:
publish:
runs-on: ubuntu-latest
environment: ${{ inputs.is-prerelease && 'staging' || 'production' }}
steps:
- uses: actions/download-artifact@v4
with:
name: ${{ inputs.artifact-name }}
path: dist
- name: Publish to PyPI
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ inputs.is-prerelease && secrets.test-pypi-token || secrets.pypi-token }}
TWINE_REPOSITORY_URL: ${{ inputs.is-prerelease && 'https://test.pypi.org/legacy/' || '' }}
run: |
pip install --upgrade pip twine
twine upload dist/*
- uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.version }}
name: Release ${{ inputs.version }}
draft: false
prerelease: ${{ inputs.is-prerelease }}
files: dist/*
generate_release_notes: true