Skip to content

Commit

Permalink
Add parameters to control releases
Browse files Browse the repository at this point in the history
Add steps to deploy to PyPI
  • Loading branch information
Crozzers committed Sep 10, 2023
1 parent ed3d094 commit 4882493
Showing 1 changed file with 94 additions and 45 deletions.
139 changes: 94 additions & 45 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,27 @@ on:
workflow_dispatch:
inputs:
version:
description: The tag to check out
description: The version to publish
required: true
gitRef:
description: The git ref to build against
required: false
testpypi:
description: Release to Test PyPI
type: boolean
default: false
pypi:
description: Release to PyPI
type: boolean
default: true
docs:
description: Publish updated documentation
type: boolean
default: true
github:
description: Draft GitHub release
type: boolean
default: true

jobs:
# test:
Expand All @@ -17,6 +36,7 @@ jobs:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.pkgVersion }}
gitRef: ${{ steps.get_version.outputs.gitRef }}
steps:
- name: Get version
id: get_version
Expand All @@ -30,56 +50,85 @@ jobs:
fi
echo "pkgVersion=$version" >> $GITHUB_OUTPUT
echo "Version: $version"
# build:
# needs: [getversion] # ,test
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
# with:
# ref: ${{ needs.getversion.outputs.version }}
# - name: Set up Python 3.11
# uses: actions/setup-python@v4
# with:
# python-version: "3.11"
# cache: "pip"
# - name: Install dependencies
# run: |
# python -m pip install .[dist]
# - name: Build
# run: |
# python -m build
# - name: Upload artifact
# uses: actions/upload-artifact@v3
# with:
# name: packages
# path: |
# dist/screen_brightness_control*.whl
# dist/screen_brightness_control*.tar.gz
# release:
# needs: [build]
# runs-on: ubuntu-latest
# steps:
# - name: Download artifact
# uses: actions/download-artifact@v3
# with:
# name: packages
# - name: Draft release
# uses: softprops/action-gh-release@v1
# with:
# draft: true
# files: "dist/*"
# name: "${{ needs.getversion.outputs.version }}"
# tag_name: ${{ needs.getversion.outputs.version }}
gitRef=""
if [ "${{ github.event.inputs.gitRef }}" != "" ]
then
gitRef="${{ github.event.inputs.gitRef }}"
else
gitRef="$version"
fi
echo "gitRef=$gitRef" >> $GITHUB_OUTPUT
echo "GIT Ref: $gitRef"
build:
needs: [getversion] # ,test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: ${{ needs.getversion.outputs.gitRef }}
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"
- name: Install dependencies
run: |
python -m pip install .[dist]
- name: Build
run: |
python -m build
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: packages
path: |
dist/screen_brightness_control*.whl
dist/screen_brightness_control*.tar.gz
release:
needs: [build]
runs-on: ubuntu-latest
environment: release-env
steps:
- name: Download artifact
uses: actions/download-artifact@v3
with:
name: packages
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: "pip"
- name: Publish to Test PyPI
if: ${{ inputs.testpypi }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.TEST_PYPI_API_TOKEN }}
packages-dir: packages/
repository-url: https://test.pypi.org/legacy/
- name: Publish to PyPI
if: ${{ inputs.pypi }}
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}
packages-dir: packages/
- name: Draft release
uses: softprops/action-gh-release@v1
with:
draft: true
files: "dist/*"
name: "${{ needs.getversion.outputs.version }}"
tag_name: ${{ needs.getversion.outputs.version }}
docs:
# needs: [build]
needs: [getversion]
if: ${{ inputs.docs }}
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@v4
with:
ref: ${{ needs.getversion.outputs.version }}
ref: ${{ needs.getversion.outputs.gitRef }}
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
Expand Down

0 comments on commit 4882493

Please sign in to comment.