Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💚 Add Schedule to Release on 01.01. and 01.06. #676

Merged
merged 4 commits into from
Dec 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 114 additions & 0 deletions .github/workflows/python-publish-scheduled.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
# This workflows will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package Scheduled

on:
schedule:
# At 01:23 on 1st January and every 6 months afterward
- cron: '23 1 1 1/6 *'

jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.11"]
os: [ubuntu-latest]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: |
python -m pip install --upgrade pip
pip install tox
- name: Run the Tests
run: |
tox -e tests
tag_and_release:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Calculate Tag Name
id: calc_tag
run: |
CURRENT_YEAR=$(date +%Y)
CURRENT_MONTH=$(date +%m)
TAG="${CURRENT_YEAR}${TAG_MONTH}.0.0"
echo "Calculated tag $TAG"
echo "::set-output name=tag::$TAG"
- name: Create and Push Tag
run: |
TAG=${{ steps.calc_tag.outputs.tag }}
git tag $TAG
git push origin $TAG
generate:
name: Generate JSON-Schemas
runs-on: ubuntu-latest
needs: tests
steps:
- name: Check out Git repository
uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install tox
run: |
python -m pip install --upgrade pip
pip install tox
- name: Build JSON Schemas
run: tox -e generate_json_schemas
env:
TARGET_VERSION: ${{ github.ref_name }}
- name: Push schemas to BO4E-Schemas repo
uses: cpina/[email protected]
env:
API_TOKEN_GITHUB: ${{ secrets.BO4E_PYTHON_GENERATE_SCHEMAS }} # this token expires on 2024-10-09
# token with repo scope
# https://github.com/Hochfrequenz/BO4E-python/settings/secrets/actions/BO4E_PYTHON_GENERATE_SCHEMAS
with:
source-directory: "json_schemas"
target-directory: "src/bo4e_schemas"
destination-github-username: "Hochfrequenz"
destination-repository-name: "BO4E-Schemas"
user-email: [email protected]
target-branch: main
commit-message: "Update JSON-Schemas - BO4E ${{ github.ref_name }}"
# This step uses the github API to automatically create a release with the same version tag
# in the BO4E-Schemas repo. For this we have to retrieve the commits SHA via the API first.
# For this, we use the lightweight tool jq (https://stedolan.github.io/jq/) to parse the JSON
# response from the API.
- name: Tag and release the new version in BO4E-Schemas
run: python bo4e_schemas_create_release.py
env:
GITHUB_TOKEN: ${{ secrets.BO4E_PYTHON_GENERATE_SCHEMAS }} # this token expires on 2024-10-09
VERSION: ${{ github.ref_name }}
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to PyPI and TestPyPI
runs-on: ubuntu-latest
# Specifying a GitHub environment, which is strongly recommended by PyPI: https://docs.pypi.org/trusted-publishers/adding-a-publisher/
environment: release
permissions:
# IMPORTANT: this permission is mandatory for trusted publishing
id-token: write
needs: [tests, generate]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10.x"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r dev_requirements/requirements-packaging.txt
- name: Build wheel and source distributions
run: python -m build
- name: Publish distribution 📦 to PyPI
if: startsWith(github.ref, 'refs/tags/v')
uses: pypa/gh-action-pypi-publish@release/v1
1 change: 0 additions & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ name: Upload Python Package

on:
release:
branches: main
types: [created, edited]

jobs:
Expand Down
Loading