-
Notifications
You must be signed in to change notification settings - Fork 5
152 lines (137 loc) · 4.8 KB
/
deploy-package-action.yml
File metadata and controls
152 lines (137 loc) · 4.8 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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
---
name: Release Salt Extension Python Package
on:
workflow_run:
types:
- completed
workflows:
- Auto PR Releases
- Tagged Releases
jobs:
get_version:
name: Get package version
runs-on: ubuntu-24.04
if: github.event.workflow_run.conclusion == 'success'
permissions:
actions: read
outputs:
version: ${{ steps.extract-version.outputs.version }}
steps:
- name: Download expected version
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: version.txt
path: ${{ runner.temp }}
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Download Python Package Artifacts
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: salt-extension-packages
path: dist
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Extract and verify package version
id: extract-version
run: |-
wheel_file="$(find dist -name '*.whl' | head -n 1)"
test -n "$wheel_file" || exit 1
unzip "$wheel_file" -d "$RUNNER_TEMP/extract"
dist_info="$(find "$RUNNER_TEMP/extract" -type d -name '*.dist-info' | head -n 1)"
test -n "$dist_info" || exit 1
package_version="$(sed -n 's/^Version:\s*\(\S*\)$/\1/p' "$dist_info/METADATA")"
test -n "$package_version" || exit 1
expected_version="$(cat "$RUNNER_TEMP/version.txt" | head -n 1)"
echo "Detected package version: $package_version"
echo "Expected version: $expected_version"
test "$package_version" = "$expected_version" || exit 1
echo "version=$expected_version" >> "$GITHUB_OUTPUT"
test_release:
name: Publish Python Package to Test PyPI
runs-on: ubuntu-24.04
needs:
- get_version
permissions:
actions: read
id-token: write
steps:
- name: Download Python Package Artifacts
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: salt-extension-packages
path: dist
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
attestations: ${{ secrets.TEST_PYPI_API_TOKEN == '' }}
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/
<<<<<<< before updating
verbose: true
=======
verbose: ${{ runner.debug == '1' }}
pypi_release:
name: Publish Python Package to PyPI
runs-on: ubuntu-24.04
needs:
- test_release
permissions:
actions: read
id-token: write
environment:
name: release
url: https://pypi.org/p/saltext.elasticsearch
steps:
- name: Download Python Package Artifacts
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: salt-extension-packages
path: dist
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
with:
attestations: ${{ secrets.PYPI_API_TOKEN == '' }}
password: ${{ secrets.PYPI_API_TOKEN }}
verbose: ${{ runner.debug == '1' }}
docs_release:
name: Deploy Docs
uses: ./.github/workflows/deploy-docs-action.yml
needs:
- pypi_release
- get_version
permissions:
actions: read
pages: write
id-token: write
gh_release:
name: Create GitHub release
runs-on: ubuntu-24.04
needs:
- pypi_release
- get_version
permissions:
actions: read
contents: write
steps:
- name: Download Python Package Artifacts
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
with:
name: salt-extension-packages
path: dist
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ github.event.workflow_run.id }}
>>>>>>> after updating
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.get_version.outputs.version }}
run: |
gh release create "v${{ needs.get_version.outputs.version }}" \
--repo="$GITHUB_REPOSITORY" \
--title="${GITHUB_REPOSITORY#*/} $VERSION" \
--generate-notes \
dist/*