Skip to content

Commit

Permalink
add publishing workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasmhughes committed Dec 27, 2023
1 parent 7be5b5d commit 0a23425
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 69 deletions.
103 changes: 42 additions & 61 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,63 +46,45 @@ jobs:
with:
changed-files: ${{ needs.get-changed-files.outputs.changed-files }}

# build-python-package:
# name: Python Package
# if: ${{ inputs.release && success() }}
# uses: salt-extensions/central-artifacts/.github/workflows/package-action.yml@main
# needs:
# - pre-commit
# with:
# version: "${{ inputs.version }}"
#
# deploy-python-package-test-pypi:
# name: Deploy Python Package (Test PyPI)
# uses: salt-extensions/central-artifacts/.github/workflows/deploy-package-action.yml@main
# if: ${{ inputs.release && success() }}
# needs:
# - pre-commit
# - test
# - docs
# - build-python-package
# secrets:
# TEST_PYPI_API_TOKEN: "${{ secrets.TEST_PYPI_API_TOKEN }}"
# with:
# version: "${{ inputs.version }}"
#
# deploy-python-package:
# name: Deploy Python Package (PyPI)
# uses: salt-extensions/central-artifacts/.github/workflows/deploy-package-action.yml@main
# if: ${{ inputs.release && success() }}
# needs:
# - pre-commit
# - test
# - docs
# - build-python-package
# - deploy-python-package-test-pypi
# secrets:
# PYPI_API_TOKEN: "${{ secrets.PYPI_API_TOKEN }}"
# with:
# test: false
# version: "${{ inputs.version }}"
#
# push-tag:
# name: Push Version Tag
# runs-on: ubuntu-latest
# permissions:
# contents: write
# if: ${{ inputs.release && success() }}
# needs:
# - build-python-package
# - deploy-python-package
# steps:
# - name: Checkout
# uses: actions/checkout@v3
# - name: Push Tag
# uses: rickstaa/action-create-tag@v1
# with:
# tag: "v${{ inputs.version }}"
# message: "Version ${{ inputs.version }}"
#
build-python-package:
name: Python Package
if: ${{ inputs.release && success() }}
uses: salt-extensions/central-artifacts/.github/workflows/package-action.yml@main
needs:
- pre-commit
with:
version: "${{ inputs.version }}"

deploy-python-package-test-pypi:
name: Deploy Python Package (Test PyPI)
uses: salt-extensions/central-artifacts/.github/workflows/deploy-package-action.yml@main
if: ${{ inputs.release && success() }}
needs:
- pre-commit
- test
- docs
- build-python-package
secrets:
TEST_PYPI_API_TOKEN: "${{ secrets.TEST_PYPI_API_TOKEN }}"
with:
version: "${{ inputs.version }}"

deploy-python-package:
name: Deploy Python Package (PyPI)
uses: salt-extensions/central-artifacts/.github/workflows/deploy-package-action.yml@main
if: ${{ inputs.release && success() }}
needs:
- pre-commit
- test
- docs
- build-python-package
- deploy-python-package-test-pypi
secrets:
PYPI_API_TOKEN: "${{ secrets.PYPI_API_TOKEN }}"
with:
test: false
version: "${{ inputs.version }}"

set-pipeline-exit-status:
# This step is just so we can make github require this step, to pass checks
# on a pull request instead of requiring all
Expand All @@ -113,10 +95,9 @@ jobs:
- pre-commit
- test
- docs
# - build-python-package
# - deploy-python-package-test-pypi
# - deploy-python-package
# - push-tag
- build-python-package
- deploy-python-package-test-pypi
- deploy-python-package
steps:
- name: Download Exit Status Files
if: always()
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/deploy-package-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Deploy Salt Extension Python Package

on:
workflow_call:
inputs:
test:
type: boolean
required: false
default: true
version:
type: string
required: true
secrets:
PYPI_API_TOKEN:
required: false
TEST_PYPI_API_TOKEN:
required: false

jobs:
build:
name: Publish Python Package to ${{ fromJSON('["PyPI", "Test PyPI"]')[inputs.test] }}
runs-on: ubuntu-latest
steps:
- name: Download Python Package Artifacts
uses: actions/download-artifact@v3
with:
name: salt-extension-${{ inputs.version }}-packages
path: dist

- name: Publish distribution to Test PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ inputs.test }}
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
repository-url: https://test.pypi.org/legacy/

- name: Publish distribution to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
if: ${{ !inputs.test }}
with:
password: ${{ secrets.PYPI_API_TOKEN }}
12 changes: 10 additions & 2 deletions .github/workflows/docs-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Set up Python 3.7 For Nox
- name: Set up Python 3.10 For Nox
uses: actions/setup-python@v4
with:
python-version: 3.7
python-version: "3.10"

- name: Install Nox
run: |
Expand All @@ -41,3 +41,11 @@ jobs:
run: |
mkdir exitstatus
echo "${{ job.status }}" > exitstatus/${{ github.job }}
- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v3
with:
name: exitstatus
path: exitstatus
if-no-files-found: error
2 changes: 1 addition & 1 deletion .github/workflows/get-changed-files.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
outputs:
changed-files: ${{ toJSON(steps.changed-files.outputs) }}
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Get Changed Files
id: changed-files
uses: dorny/paths-filter@v2
Expand Down
50 changes: 50 additions & 0 deletions .github/workflows/package-action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Salt Extension Python Package

on:
workflow_call:
inputs:
version:
required: true
type: string

jobs:
build:
name: Build Python Packages (wheel and sdist)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: "3.10"

- name: Install build
run: >-
python -m
pip install
build
--user
- name: Echo Version
run: echo "${{ inputs.version }}"

- name: Setup Version
run: echo "${{ inputs.version }}" > version.txt

- name: Build Wheel
run: python -m build --outdir dist/

- name: Upload build artifacts
uses: actions/upload-artifact@v3
if: always()
with:
name: salt-extension-${{ inputs.version }}-packages
path: dist/*
retention-days: 5

- name: Set Exit Status
if: always()
run: |
mkdir exitstatus
echo "${{ job.status }}" > exitstatus/${{ github.job }}
File renamed without changes.
35 changes: 30 additions & 5 deletions .github/workflows/test-action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:

strategy:
fail-fast: false
max-parallel: 4
max-parallel: 5
matrix:
python-version:
- '3.8'
Expand Down Expand Up @@ -134,7 +134,16 @@ jobs:
if: always()
run: |
mkdir exitstatus
echo "${{ job.status }}" > exitstatus/${{ github.job }}
echo "${{ job.status }}" > exitstatus/${{ github.job }}-Py{{ matrix.python-version }}-Salt{{ matrix.salt-version }}
- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v3
with:
name: exitstatus
path: exitstatus
if-no-files-found: error


Windows:
runs-on: windows-latest
Expand Down Expand Up @@ -263,7 +272,7 @@ jobs:
- name: Upload Logs
if: always()
uses: actions/upload-artifact@main
uses: actions/upload-artifact@v3
with:
name: runtests-${{ runner.os }}-py${{ matrix.python-version }}-Salt${{ matrix.salt-version }}.log
path: artifacts/runtests-*.log
Expand All @@ -272,7 +281,15 @@ jobs:
if: always()
run: |
mkdir exitstatus
echo "${{ job.status }}" > exitstatus/${{ github.job }}
echo "${{ job.status }}" > exitstatus/${{ github.job }}-Py{{ matrix.python-version }}-Salt{{ matrix.salt-version }}
- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v3
with:
name: exitstatus
path: exitstatus
if-no-files-found: error

macOS:
runs-on: macOS-latest
Expand Down Expand Up @@ -395,4 +412,12 @@ jobs:
if: always()
run: |
mkdir exitstatus
echo "${{ job.status }}" > exitstatus/${{ github.job }}
echo "${{ job.status }}" > exitstatus/${{ github.job }}-Py{{ matrix.python-version }}-Salt{{ matrix.salt-version }}
- name: Upload Exit Status
if: always()
uses: actions/upload-artifact@v3
with:
name: exitstatus
path: exitstatus
if-no-files-found: error

0 comments on commit 0a23425

Please sign in to comment.