Fixes #12
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Toolkit Library Deploy | |
concurrency: deploy | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- 'pretix_extended_api/**/*' | |
- 'pyproject.toml' | |
workflow_dispatch: | |
inputs: | |
comment-id: | |
description: 'The comment-id of the slash command' | |
required: true | |
event-number: | |
description: 'The event-id of the slash command' | |
required: true | |
jobs: | |
publish-library: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
persist-credentials: false | |
ref: ${{ github.ref }} | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: 3.9 | |
- name: Install pdm | |
run: pip install pdm | |
- name: Metadata | |
id: metadata | |
run: echo "::set-output name=commit::$(git rev-parse HEAD)" | |
- name: Find Release Comment | |
uses: peter-evans/find-comment@v1 | |
id: find_comment | |
if: ${{ github.ref != 'refs/heads/main' }} | |
with: | |
token: ${{ secrets.BOT_TOKEN }} | |
issue-number: ${{ github.event.inputs.event-number }} | |
comment-author: pythonitaliabot | |
body-includes: "Pre-release" | |
- name: Create or update comment | |
id: initial-comment | |
uses: peter-evans/create-or-update-comment@v1 | |
if: ${{ github.ref != 'refs/heads/main' }} | |
with: | |
token: ${{ secrets.BOT_TOKEN }} | |
comment-id: ${{ steps.find_comment.outputs.comment-id }} | |
issue-number: ${{ github.event.inputs.event-number }} | |
body: | | |
# Pre-release | |
:wave: | |
Releasing commit [${{ steps.metadata.outputs.commit }}] to PyPi as pre-release! :package: | |
edit-mode: replace | |
- name: Install pdm-manage-version | |
run: pdm plugin add pdm-manage-version | |
- name: Update version | |
if: ${{ github.ref == 'refs/heads/main' }} | |
run: pdm version patch | |
- name: Update to pre-release version | |
if: ${{ github.ref != 'refs/heads/main' }} | |
run: | | |
pdm version patch | |
current_version=$(pdm version) | |
pdm version $current_version-dev.$(date '+%s') | |
- name: Build & Publish | |
id: release | |
env: | |
PDM_PUBLISH_PASSWORD: ${{ secrets.PYPI_TOKEN }} | |
run: | | |
pdm publish --username __token__ | |
current_version=$(pdm version) | |
echo "::set-output name=version::$current_version" | |
- name: Commit version | |
if: ${{ github.ref == 'refs/heads/main' }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }} | |
run: | | |
current_version=$(pdm version) | |
git remote set-url origin https://${{ secrets.BOT_TOKEN }}@github.com/${{ github.repository }} | |
git config user.name "Python Italia [bot]" | |
git config user.email "[email protected]" | |
git add pyproject.toml | |
git commit -m "🔨 Publish plugin v$current_version [skip ci]" | |
git push | |
- name: Create or update comment | |
uses: peter-evans/create-or-update-comment@v1 | |
if: ${{ github.ref != 'refs/heads/main' }} | |
with: | |
token: ${{ secrets.BOT_TOKEN }} | |
comment-id: ${{ steps.initial-comment.outputs.comment-id }} | |
issue-number: ${{ github.event.inputs.event-number }} | |
body: | | |
# Pre-release | |
:wave: | |
Pre-release **${{ steps.release.outputs.version }}** [${{ steps.metadata.outputs.commit }}] has been released on PyPi! :rocket: | |
You can try it by doing: | |
```shell | |
poetry add pretix-plugin-extended-api==${{ steps.release.outputs.version }} | |
``` | |
edit-mode: replace |