-
Notifications
You must be signed in to change notification settings - Fork 0
81 lines (81 loc) · 2.75 KB
/
cd.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
---
name: CD
permissions:
contents: write
pull-requests: write
on:
workflow_run:
workflows: [CI]
types: [completed]
branches: [main]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
build:
name: Continuous Deployment
permissions: write-all
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.10' # Replace with your Python version
- name: Install dependencies
run: |
pip install poetry
npm install -g auto-changelog
- name: Build the package
run: |
poetry install --only main
- name: Determine Version Bump
id: determine_version_bump
run: |
MESSAGE=$(git log -1 --pretty=format:'%s')
if [[ $MESSAGE == build* ]]; then
echo "::set-output name=bump::patch"
else
echo "::set-output name=bump::minor"
fi
- name: Update package version
id: update-package-version
run: |
poetry version ${{ steps.determine_version_bump.outputs.bump }}
echo "PACKAGE_VERSION=$(poetry version | awk '{print $NF}')" >> "$GITHUB_OUTPUT"
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git add pyproject.toml
git commit -m "Bump ${{ steps.determine_version_bump.outputs.bump }} version"
git push
- name: Create Tag
env:
PACKAGE_VERSION: ${{ steps.update-package-version.outputs.PACKAGE_VERSION }}
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
git tag -a $PACKAGE_VERSION -m "chore: Bumping $PACKAGE_VERSION"
git push origin --tags
npm i -g auto-changelog
auto-changelog
git add CHANGELOG.md
git commit -m "chore: updating changelog"
git push origin main
- name: Create Release
if: github.ref == 'refs/heads/main'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PACKAGE_VERSION: ${{ steps.update-package-version.outputs.PACKAGE_VERSION }}
with:
tag_name: ${{ env.PACKAGE_VERSION }}
release_name: ${{ env.PACKAGE_VERSION }}
body_path: CHANGELOG.md
draft: false
prerelease: false
on-failure:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'failure' }}
steps:
- run: echo 'The triggering workflow failed'