Skip to content

Feat/original split + Fix/cached download #65

Feat/original split + Fix/cached download

Feat/original split + Fix/cached download #65

Workflow file for this run

name: test and release
on:
pull_request:
branches:
- next
- main
workflow_dispatch:
inputs:
target_branch:
description: "The target branch to release to"
required: true
default: "main"
version:
description: "The version number to release"
required: true
changelog:
description: "Changelog:<br><textarea name='changelog' rows='5' cols='50'></textarea>"
required: false
jobs:
pytest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install poetry
run: |
python -m pip install poetry
- name: Install dependencies with updated version
run: poetry install
- name: Run pytest
run: poetry run pytest
prerelease:
needs: pytest
if: github.event_name == 'workflow_dispatch' && github.event.inputs.target_branch == 'main'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
ref: "next"
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Update version number
run: poetry version ${{ github.event.inputs.version }}
- name: Disable branch protection next
run: |
curl -X PUT -H "Authorization: Bearer ${{ secrets.TORCHCHRONOS_PROT }}" \
-H "Accept: application/vnd.github.luke-cage-preview+json" \
https://api.github.com/repos/mauricekraus/torchchronos/branches/next/protection \
-d '{"restrictions": null, "required_pull_request_reviews": null, "required_status_checks": null, "enforce_admins": null}'
- name: Commit version changes
run: |
git config user.name "GitHub Actions"
git config user.email "<>"
git add pyproject.toml
git commit -m "Bump version to ${{ github.event.inputs.version }}"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: "next"
- name: Enable branch protection next
run: |
curl -X PUT -H "Authorization: Bearer ${{ secrets.TORCHCHRONOS_PROT }}" \
-H "Accept: application/vnd.github.luke-cage-preview+json" \
https://api.github.com/repos/mauricekraus/torchchronos/branches/next/protection \
-d '{"required_pull_request_reviews": {"dismiss_stale_reviews": true, "require_code_owner_reviews": true}}'
release:
needs: prerelease
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: "main"
- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: "3.10"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install poetry
- name: Disable branch protection main
run: |
curl -X PUT -H "Authorization: Bearer ${{ secrets.TORCHCHRONOS_PROT }}" \
-H "Accept: application/vnd.github.luke-cage-preview+json" \
https://api.github.com/repos/mauricekraus/torchchronos/branches/main/protection \
-d '{"restrictions": null, "required_pull_request_reviews": null, "required_status_checks": null, "enforce_admins": null}'
- name: Checkout and fetch next
uses: actions/checkout@v3
with:
ref: "next"
- name: Checkout main
uses: actions/checkout@v3
with:
ref: "main"
- name: Configure git
run: |
git config user.name "GitHub Actions"
git config user.email "<>"
- name: Merge next -> main
run: |
git fetch origin
git merge --allow-unrelated-histories --strategy-option theirs origin/next
git push origin main
- name: Enable branch protection main
run: |
curl -X PUT -H "Authorization: Bearer ${{ secrets.TORCHCHRONOS_PROT }}" \
-H "Accept: application/vnd.github.luke-cage-preview+json" \
https://api.github.com/repos/mauricekraus/torchchronos/branches/main/protection \
-d '{"required_pull_request_reviews": {"dismiss_stale_reviews": true, "require_code_owner_reviews": true}}'
- name: Install dependencies with updated version
run: poetry install
- name: Build and publish package
run: |
poetry build
poetry config pypi-token.pypi ${{ secrets.POETRY_PYPI_TOKEN }}
poetry publish
- name: Create GitHub release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.event.inputs.version }}
release_name: Release ${{ github.event.inputs.version }}
body: |
Release ${{ github.event.inputs.version }}
${{ github.event.inputs.changelog }}
draft: false
prerelease: ${{ contains(github.event.inputs.version, 'post') }}