Skip to content

Release on tag

Release on tag #19

Workflow file for this run

name: Release on tag
on:
push:
tags:
- "*"
workflow_dispatch:
inputs:
version:
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:
# uses: ./.github/workflows/tests.yaml
getversion:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get_version.outputs.pkgVersion }}
gitRef: ${{ steps.get_version.outputs.gitRef }}
steps:
- name: Get version
id: get_version
run: |
version=""
if [ "${{ github.event_name }}" == "workflow_dispatch" ]
then
version="${{ github.event.inputs.version }}"
else
version="$GITHUB_REF_NAME"
fi
echo "pkgVersion=$version" >> $GITHUB_OUTPUT
echo "Version: $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"
- name: Debug tree
run: |
tree
- 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:
if: ${{ inputs.docs }}
needs: [release]
runs-on: ubuntu-latest
steps:
- name: Checkout source
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 .[docs]
- name: Checkout docs
uses: actions/checkout@v4
with:
ref: gh-pages
path: docs/docs
- name: Generate docs
run: |
make docs
- name: Configure Git
working-directory: docs/docs
run: |
git config --global user.name "Github Actions [Bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
- name: Commit and Push
working-directory: docs/docs
run: |
git add -A
git commit -m "Bump ${{ needs.getversion.outputs.version }}"
git push