-
Notifications
You must be signed in to change notification settings - Fork 7
115 lines (95 loc) · 3.24 KB
/
cd_release.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
107
108
109
110
111
112
113
114
115
---
name: CD - Publish
on:
release:
types:
- published
env:
PUBLISH_UPDATE_BRANCH: develop
GIT_USER_NAME: The AiiDA Team
GIT_USER_EMAIL: [email protected]
jobs:
publish:
name: Update CHANGELOG
if: github.repository == 'aiidateam/aiida-optimade' && startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: 3.9
- name: Install Python dependencies
run: |
python -m pip install -U pip
pip install -U setuptools wheel
pip install -U -e .[dev]
- name: Update changelog
uses: CharMixer/auto-changelog-action@v1
with:
token: ${{ secrets.RELEASE_PAT }}
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
- name: Update version - Commit changes and update tag
run: .github/utils/update_version.sh
- name: Update '${{ env.PUBLISH_UPDATE_BRANCH }}'
uses: CasperWA/push-protected@v2
with:
token: ${{ secrets.RELEASE_PAT }}
branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
sleep: 15
force: true
tags: true
- name: Get tagged versions
run: echo "PREVIOUS_VERSION=$(git tag -l --sort -version:refname | sed -n 2p)" >> $GITHUB_ENV
- name: Create release-specific changelog
uses: CharMixer/auto-changelog-action@v1
with:
token: ${{ secrets.RELEASE_PAT }}
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
since_tag: ${{ env.PREVIOUS_VERSION }}
output: release_changelog.md
- name: Append changelog to release body
run: |
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} --jq '.body' > release_body.md
cat release_changelog.md >> release_body.md
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} -X PATCH -F body='@release_body.md'
env:
GITHUB_TOKEN: ${{ secrets.RELEASE_PAT }}
- name: Build source distribution
run: python ./setup.py sdist
- name: Publish package to TestPyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
user: __token__
password: ${{ secrets.pypi_password }}
update-stable:
name: Update `stable` branch
needs: publish
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: stable
persist-credentials: false
- name: Setup git config
run: |
git config --global user.name "${GIT_USER_NAME}"
git config --global user.email "${GIT_USER_EMAIL}"
- name: Make `stable` branch equal to `${{ env.PUBLISH_UPDATE_BRANCH }}` branch
run: git merge --ff-only origin/${{ env.PUBLISH_UPDATE_BRANCH }}
- name: Update `stable` branch
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.RELEASE_PAT }}
branch: stable