This repository has been archived by the owner on Jun 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
106 lines (98 loc) · 3.48 KB
/
deploy-toolkit.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: Toolkit Library Deploy
concurrency: deploy
on:
push:
branches:
- main
paths:
- 'pythonit_toolkit/**/*'
- '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.11
- name: Install poetry
run: pip install poetry
- 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: Update version
if: ${{ github.ref == 'refs/heads/main' }}
run: poetry version patch
- name: Update to pre-release version
if: ${{ github.ref != 'refs/heads/main' }}
run: |
poetry version patch
poetry version $(poetry version -s)-dev.$(date '+%s')
- name: Build & Publish
id: release
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
run: |
poetry publish --username __token__ --build
echo "::set-output name=version::$(poetry version -s)"
- name: Commit version
if: ${{ github.ref == 'refs/heads/main' }}
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
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 Toolkit v$(poetry version -s) [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 pythonit-toolkit==${{ steps.release.outputs.version }}
```
edit-mode: replace