Skip to content

Commit

Permalink
[CI/CD] Update release workflow
Browse files Browse the repository at this point in the history
Start with a minimal approach for releases based on action version string of current branch/tag
  • Loading branch information
MichaIng committed Dec 23, 2022
1 parent ebf45bd commit 268c8a6
Showing 1 changed file with 9 additions and 38 deletions.
47 changes: 9 additions & 38 deletions .github/workflows/pypi_release.yml
Original file line number Diff line number Diff line change
@@ -1,55 +1,26 @@
name: PyPI release

# This workflow build and upload a pre-release package to test.pypi.org
# The version is postfixed with .devYYYYMMDDHHMM, allowing to upload each minute.
# This workflow is run each day at 23:59 UTC, or on demand.
# When run on schedule, a new package is generated only if latest commit is less than 1 day.
#
# Note : a scheduled workflow must be on the default branch to be executed.
#

on:
workflow_dispatch:
# schedule:
# - cron: '59 23 * * *'
on: workflow_dispatch

permissions:
contents: read

jobs:
deploy:

runs-on: ubuntu-latest
env:
should_run: true

release:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
with:
ref: dev
- name: print latest_commit
run: git log -n 1
- name: check latest commit is less than a day
if: ${{ github.event_name == 'schedule' }}
run: test -z "$(git log -n 1 --after='24 hours')" && echo "should_run=false" >> $GITHUB_ENV ; true
- name: Set up Python
if: ${{ env.should_run != 'false' }}
uses: actions/setup-python@v3
- uses: actions/setup-python@v4
with:
python-version: '3.x'
check-latest: true
- name: Install dependencies
if: ${{ env.should_run != 'false' }}
run: |
python -m pip install --upgrade pip
pip install -U build twine wheel
- name: build dev version
if: ${{ env.should_run != 'false' }}
run: sed -i "s/\"$/.dev$(date +%Y%m%d%H%M)\"/" motioneye/__init__.py
python -m pip install --upgrade pip setuptools wheel
python -m pip install --upgrade build twine
- name: Build package
if: ${{ env.should_run != 'false' }}
run: python -m build
- name: Publish package
if: ${{ env.should_run != 'false' }}
# run: twine upload --repository testpypi -u __token__ -p ${{ secrets.TEST_PYPI_API_TOKEN }} dist/*
run: twine upload --repository pypi -u __token__ -p ${{ secrets.PYPI_TOKEN }} dist/*
run: twine upload -r testpypi -u '__token__' -p '${{ secrets.TEST_PYPI_API_TOKEN }}' dist/*
#run: twine upload -r pypi -u '__token__' -p '${{ secrets.PYPI_TOKEN }}' dist/*

0 comments on commit 268c8a6

Please sign in to comment.