Skip to content

Commit 77e24b7

Browse files
1 parent bfb9635 commit 77e24b7

21 files changed

+659
-263
lines changed

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Autogenerated. Do not edit this by hand, use `copier update`.
22
---
3-
_commit: 0.7.5
3+
_commit: 0.9.0
44
_src_path: https://github.com/salt-extensions/salt-extension-copier
55
author: Will Sinatra
66
author_email: durrendal@lambdacreate.com
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
---
2+
name: upload-exitstatus
3+
description: Upload a job's status as an artifact
4+
inputs:
5+
artifact_prefix:
6+
required: false
7+
default: exitstatus-
8+
name:
9+
required: false
10+
default: ''
11+
12+
runs:
13+
using: composite
14+
15+
steps:
16+
17+
- name: Set Exit Status
18+
if: always()
19+
env:
20+
OUTFILE: exitstatus/${{ inputs.name == '' && github.job || inputs.name }}
21+
shell: bash
22+
run: |
23+
mkdir exitstatus
24+
echo "${{ job.status }}" > "$OUTFILE"
25+
26+
- name: Upload Exit Status
27+
if: always()
28+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
29+
with:
30+
name: ${{ inputs.artifact_prefix }}${{ inputs.name == '' && github.job || inputs.name }}
31+
path: exitstatus
32+
if-no-files-found: error

.github/workflows/ci.yml

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3,37 +3,24 @@ name: CI
33

44
on:
55
workflow_call:
6-
inputs:
7-
deploy-docs:
8-
required: false
9-
type: boolean
10-
default: false
11-
release:
12-
required: false
13-
type: boolean
14-
default: false
15-
version:
16-
required: false
17-
type: string
18-
secrets:
19-
PYPI_API_TOKEN:
20-
required: false
21-
TEST_PYPI_API_TOKEN:
22-
required: false
23-
246

257
jobs:
268
get-changed-files:
279
name: Get Changed Files
2810
uses: ./.github/workflows/get-changed-files.yml
11+
permissions:
12+
contents: read
13+
pull-requests: read # for dorny/paths-filter to read pull requests
2914

3015
pre-commit:
3116
name: Pre-Commit
32-
uses: ./.github/workflows/pre-commit-action.yml
3317
needs:
3418
- get-changed-files
19+
uses: ./.github/workflows/pre-commit-action.yml
3520
with:
3621
changed-files: ${{ needs.get-changed-files.outputs.changed-files }}
22+
permissions:
23+
contents: read
3724

3825
test:
3926
name: Test
@@ -46,6 +33,7 @@ jobs:
4633
needs:
4734
- pre-commit
4835
uses: ./.github/workflows/docs-action.yml
36+
<<<<<<< before updating
4937

5038
check-prepare-release:
5139
name: Check if we can prepare release PR
@@ -78,33 +66,16 @@ jobs:
7866
- check-prepare-release
7967
- docs
8068
- test
69+
=======
70+
>>>>>>> after updating
8171
permissions:
82-
contents: write
83-
pull-requests: write
84-
uses: ./.github/workflows/prepare-release-action.yml
85-
86-
deploy-docs:
87-
name: Deploy Docs
88-
uses: ./.github/workflows/deploy-docs-action.yml
89-
# Only build doc deployments from the default branch of the repo and never for PRs,
90-
# unless the triggering event was the release PR being merged.
91-
if: >-
92-
inputs.deploy-docs &&
93-
(
94-
github.event_name != 'pull_request' ||
95-
inputs.release
96-
) &&
97-
github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
98-
needs:
99-
- docs
100-
- test
72+
contents: read
10173

10274
build-python-package:
10375
name: Python Package
104-
if: ${{ inputs.release && success() }}
105-
uses: ./.github/workflows/package-action.yml
10676
needs:
10777
- pre-commit
78+
<<<<<<< before updating
10879
with:
10980
version: "${{ inputs.version }}"
11081

@@ -173,3 +144,8 @@ jobs:
173144
if: always()
174145
run:
175146
echo "All workflows finished"
147+
=======
148+
uses: ./.github/workflows/package-action.yml
149+
permissions:
150+
contents: read
151+
>>>>>>> after updating

.github/workflows/deploy-docs-action.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@ on:
1111
required: false
1212
default: html-docs
1313

14+
15+
permissions:
16+
actions: read # For downloading artifacts of other runs when called via workflow_run trigger
17+
pages: write
18+
id-token: write
19+
1420
jobs:
1521

1622
# The released docs are not versioned currently, only the latest ones are deployed.
@@ -31,18 +37,21 @@ jobs:
3137
name: github-pages
3238
url: ${{ steps.deployment.outputs.page_url }}
3339

34-
permissions:
35-
pages: write
36-
id-token: write
37-
3840
runs-on: ubuntu-24.04
3941

4042
steps:
43+
4144
- name: Download built docs
45+
<<<<<<< before updating
4246
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
47+
=======
48+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
49+
>>>>>>> after updating
4350
with:
4451
name: ${{ inputs.artifact-name }}
4552
path: html-docs
53+
github-token: ${{ github.token }}
54+
run-id: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.id || github.run_id }}
4655

4756
- name: Upload GitHub Pages artifact
4857
uses: actions/upload-pages-artifact@7b1f4a764d45c48632c6b24a0339c27f5614fb0b # v4.0.0
@@ -63,16 +72,16 @@ jobs:
6372
name: html-docs-pages
6473
failOnError: false
6574

66-
- name: Set Exit Status
67-
if: always()
68-
run: |
69-
mkdir exitstatus
70-
echo "${{ job.status }}" > exitstatus/${{ github.job }}
75+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
7176

7277
- name: Upload Exit Status
7378
if: always()
79+
<<<<<<< before updating
7480
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
7581
with:
7682
name: exitstatus-${{ github.job }}
7783
path: exitstatus
7884
if-no-files-found: error
85+
=======
86+
uses: ./.github/actions/upload-exitstatus
87+
>>>>>>> after updating

.github/workflows/deploy-package-action.yml

Lines changed: 127 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,152 @@
11
---
2-
name: Deploy Salt Extension Python Package
2+
name: Release Salt Extension Python Package
33

44
on:
5-
workflow_call:
6-
inputs:
7-
test:
8-
type: boolean
9-
required: false
10-
default: true
11-
version:
12-
type: string
13-
required: true
14-
secrets:
15-
PYPI_API_TOKEN:
16-
required: false
17-
TEST_PYPI_API_TOKEN:
18-
required: false
5+
workflow_run:
6+
types:
7+
- completed
8+
workflows:
9+
- Auto PR Releases
10+
- Tagged Releases
1911

2012
jobs:
21-
build:
22-
name: Publish Python Package to ${{ ! inputs.test && 'PyPI' || 'Test PyPI' }}
13+
get_version:
14+
name: Get package version
2315
runs-on: ubuntu-24.04
16+
if: github.event.workflow_run.conclusion == 'success'
17+
permissions:
18+
actions: read
19+
outputs:
20+
version: ${{ steps.extract-version.outputs.version }}
2421

2522
steps:
23+
- name: Download expected version
24+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
25+
with:
26+
name: version.txt
27+
path: ${{ runner.temp }}
28+
github-token: ${{ secrets.GITHUB_TOKEN }}
29+
run-id: ${{ github.event.workflow_run.id }}
30+
2631
- name: Download Python Package Artifacts
32+
<<<<<<< before updating
2733
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
34+
=======
35+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
36+
>>>>>>> after updating
2837
with:
29-
name: salt-extension-${{ inputs.version }}-packages
38+
name: salt-extension-packages
3039
path: dist
40+
github-token: ${{ secrets.GITHUB_TOKEN }}
41+
run-id: ${{ github.event.workflow_run.id }}
42+
43+
- name: Extract and verify package version
44+
id: extract-version
45+
run: |-
46+
wheel_file="$(find dist -name '*.whl' | head -n 1)"
47+
test -n "$wheel_file" || exit 1
48+
unzip "$wheel_file" -d "$RUNNER_TEMP/extract"
49+
dist_info="$(find "$RUNNER_TEMP/extract" -type d -name '*.dist-info' | head -n 1)"
50+
test -n "$dist_info" || exit 1
51+
package_version="$(sed -n 's/^Version:\s*\(\S*\)$/\1/p' "$dist_info/METADATA")"
52+
test -n "$package_version" || exit 1
53+
expected_version="$(cat "$RUNNER_TEMP/version.txt" | head -n 1)"
54+
echo "Detected package version: $package_version"
55+
echo "Expected version: $expected_version"
56+
test "$package_version" = "$expected_version" || exit 1
57+
echo "version=$expected_version" >> "$GITHUB_OUTPUT"
58+
59+
test_release:
60+
name: Publish Python Package to Test PyPI
61+
runs-on: ubuntu-24.04
62+
needs:
63+
- get_version
64+
permissions:
65+
actions: read
66+
id-token: write
67+
68+
steps:
69+
- name: Download Python Package Artifacts
70+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
71+
with:
72+
name: salt-extension-packages
73+
path: dist
74+
github-token: ${{ secrets.GITHUB_TOKEN }}
75+
run-id: ${{ github.event.workflow_run.id }}
3176

3277
- name: Publish distribution to Test PyPI
33-
uses: pypa/gh-action-pypi-publish@1bb664cc2ddedbbfdde43d4ac135d5836b7bf40f # v1.11.0
34-
if: ${{ inputs.test }}
78+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
3579
with:
36-
attestations: false
80+
attestations: ${{ secrets.TEST_PYPI_API_TOKEN == '' }}
3781
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
3882
repository-url: https://test.pypi.org/legacy/
83+
verbose: ${{ runner.debug == '1' }}
84+
85+
pypi_release:
86+
name: Publish Python Package to PyPI
87+
runs-on: ubuntu-24.04
88+
needs:
89+
- test_release
90+
permissions:
91+
actions: read
92+
id-token: write
93+
environment:
94+
name: release
95+
url: https://pypi.org/p/saltext.nebula
96+
97+
steps:
98+
- name: Download Python Package Artifacts
99+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
100+
with:
101+
name: salt-extension-packages
102+
path: dist
103+
github-token: ${{ secrets.GITHUB_TOKEN }}
104+
run-id: ${{ github.event.workflow_run.id }}
105+
106+
- name: Publish distribution to PyPI
107+
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # v1.13.0
108+
with:
109+
attestations: ${{ secrets.PYPI_API_TOKEN == '' }}
110+
password: ${{ secrets.PYPI_API_TOKEN }}
111+
verbose: ${{ runner.debug == '1' }}
112+
113+
docs_release:
114+
name: Deploy Docs
115+
uses: ./.github/workflows/deploy-docs-action.yml
116+
needs:
117+
- pypi_release
118+
- get_version
119+
permissions:
120+
actions: read
121+
pages: write
122+
id-token: write
123+
124+
gh_release:
125+
name: Create GitHub release
126+
runs-on: ubuntu-24.04
127+
needs:
128+
- pypi_release
129+
- get_version
130+
permissions:
131+
actions: read
132+
contents: write
133+
134+
steps:
135+
- name: Download Python Package Artifacts
136+
uses: actions/download-artifact@70fc10c6e5e1ce46ad2ea6f2b72d43f7d47b13c3 # v8.0.0
137+
with:
138+
name: salt-extension-packages
139+
path: dist
140+
github-token: ${{ secrets.GITHUB_TOKEN }}
141+
run-id: ${{ github.event.workflow_run.id }}
39142

40143
- name: Create GitHub Release
41-
if: ${{ !inputs.test }}
42144
env:
43145
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
146+
VERSION: ${{ needs.get_version.outputs.version }}
44147
run: |
45-
gh release create "v${{ inputs.version }}" \
148+
gh release create "v${{ needs.get_version.outputs.version }}" \
46149
--repo="$GITHUB_REPOSITORY" \
47-
--title="${GITHUB_REPOSITORY#*/} ${{ inputs.version }}" \
150+
--title="${GITHUB_REPOSITORY#*/} $VERSION" \
48151
--generate-notes \
49152
dist/*
50-
51-
- name: Publish distribution to PyPI
52-
uses: pypa/gh-action-pypi-publish@1bb664cc2ddedbbfdde43d4ac135d5836b7bf40f # v1.11.0
53-
if: ${{ !inputs.test }}
54-
with:
55-
# Attestations are only submitted when using Trusted Publishing,
56-
# which is triggered by secrets.PYPI_API_TOKEN not being set.
57-
# They don't work with reusable workflows at the moment.
58-
# It's related to https://github.com/pypi/warehouse/issues/11096
59-
attestations: false
60-
password: ${{ secrets.PYPI_API_TOKEN }}

0 commit comments

Comments
 (0)