This repository was archived by the owner on Sep 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (66 loc) · 2.72 KB
/
cd.yml
File metadata and controls
79 lines (66 loc) · 2.72 KB
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
name: "CD"
on:
workflow_dispatch:
inputs:
release-type:
description: "Type of release?"
required: true
type: choice
options:
- patch
- minor
- major
jobs:
release:
name: "Release"
if: github.ref == 'refs/heads/master'
runs-on: ubuntu-latest
steps:
- name: "Checkout code"
uses: actions/checkout@v2
with:
token: ${{ secrets.GH_PAT }}
- name: "Set up Python"
uses: actions/setup-python@v2
with:
python-version: '3.7'
- name: "Install Poetry"
uses: snok/install-poetry@5e4414407e59f94f2148bcb253917dfc22dee7d9 # v1.3.0
with:
virtualenvs-create: true
virtualenvs-in-project: true
- name: "Bump pyproject.toml version"
id: bump
run: |
poetry version ${{ github.event.inputs.release-type }}
echo "::set-output name=version::$(poetry version --short)"
- name: "Bump `apilytics.__version__`"
run: sed -i 's/^__version__ *=.*/__version__ = "${{ steps.bump.outputs.version }}"/' apilytics/__init__.py
- name: "Update the changelog"
# Find the first line that starts with `###` or `## [<number>` from the CHANGELOG and insert the new version header before it.
run: sed -i "0,/^\(###\|## *\[[0-9]\).*/{s//## [${{ steps.bump.outputs.version }}] - $(date -u '+%Y-%m-%d')\n\n&/}" CHANGELOG.md
- name: "Extract version's changelog for release notes"
# 1. Find the lines between the first `## [<number>` and the second `## [<number>`.
# 2. Remove all leading and trailing newlines from the output.
run: sed '1,/^## *\[[0-9]/d;/^## *\[[0-9]/Q' CHANGELOG.md | sed -e :a -e '/./,$!d;/^\n*$/{$d;N;};/\n$/ba' > release_notes.txt
- name: "Commit and tag the changes"
run: |
git config user.name 'github-actions'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add pyproject.toml apilytics/__init__.py CHANGELOG.md
git commit --message='Release ${{ steps.bump.outputs.version }}'
git tag --annotate --message='' v${{ steps.bump.outputs.version }}
- name: "Build the wheel"
run: poetry build
- name: "Publish to PyPI"
run: poetry publish
env:
POETRY_PYPI_TOKEN_PYPI: ${{ secrets.PYPI_TOKEN }}
- name: "Push the changes"
run: git push --follow-tags
- name: "Create a GitHub release"
uses: softprops/action-gh-release@1e07f4398721186383de40550babbdf2b84acfc5 # v1
with:
tag_name: v${{ steps.bump.outputs.version }}
name: v${{ steps.bump.outputs.version }}
body_path: release_notes.txt