Skip to content

Commit 0641370

Browse files
authored
Use CasperWA/gh-actions workflows (#60)
Use CasperWA/gh-actions workflows. This implements the use of the currently available workflows in the external repository for: - Releasing package to PyPI and deploy documentation - Check and update dependencies in `pyproject.toml` The dependency update workflow has been tested and is considered properly implemented and working at this point. The release workflow still needs to be tested with a proper release. Then it should be updated, setting `test` to `false`, and probably tested again.
1 parent 348ca08 commit 0641370

6 files changed

Lines changed: 39 additions & 354 deletions

File tree

.github/utils/pyproject_toml_update_pr_body.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

.github/utils/release_tag_msg.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

.github/workflows/cd_dependencies.yml

Lines changed: 0 additions & 77 deletions
This file was deleted.

.github/workflows/cd_release.yml

Lines changed: 17 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -5,126 +5,22 @@ on:
55
types:
66
- published
77

8-
env:
9-
PUBLISH_UPDATE_BRANCH: main
10-
GIT_USER_NAME: "TEAM 4.0[bot]"
11-
GIT_USER_EMAIL: "Team4.0@SINTEF.no"
12-
138
jobs:
14-
update-and-publish:
15-
name: Update CHANGELOG and version and publish to PyPI
16-
runs-on: ubuntu-latest
9+
publish-package-and-docs:
10+
name: Call external workflow
11+
uses: CasperWA/gh-actions/.github/workflows/cd_release.yml@main
1712
if: github.repository == 'SINTEF/oteapi-optimade' && startsWith(github.ref, 'refs/tags/v')
18-
19-
steps:
20-
- name: Checkout repository
21-
uses: actions/checkout@v3
22-
with:
23-
fetch-depth: 0
24-
25-
- name: Set up Python 3.9
26-
uses: actions/setup-python@v4
27-
with:
28-
python-version: "3.9"
29-
30-
- name: Install Python dependencies
31-
run: |
32-
python -m pip install -U pip
33-
pip install -U setuptools wheel flit
34-
pip install -U -e .[dev]
35-
36-
- name: Update changelog
37-
uses: CharMixer/auto-changelog-action@v1
38-
with:
39-
token: ${{ secrets.GITHUB_TOKEN }}
40-
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
41-
42-
- name: Set up git user
43-
run: |
44-
git config --global user.name "${GIT_USER_NAME}"
45-
git config --global user.email "${GIT_USER_EMAIL}"
46-
47-
- name: Update version and tag
48-
run: |
49-
invoke setver --version="${GITHUB_REF#refs/tags/}"
50-
51-
git add oteapi_optimade/__init__.py tests/static/test_optimade_config.yml CHANGELOG.md
52-
git commit -m "Release ${GITHUB_REF#refs/tags/} - Changelog"
53-
54-
TAG_MSG=.github/utils/release_tag_msg.txt
55-
sed -i "s|TAG_NAME|${GITHUB_REF#refs/tags/}|" "${TAG_MSG}"
56-
git tag -af -F "${TAG_MSG}" ${GITHUB_REF#refs/tags/}
57-
58-
- name: Build source distribution
59-
run: |
60-
# First, clean the git tree
61-
git checkout -- .
62-
flit build
63-
64-
- name: Update '${{ env.PUBLISH_UPDATE_BRANCH }}'
65-
uses: CasperWA/push-protected@v2
66-
with:
67-
token: ${{ secrets.RELEASE_PAT }}
68-
branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
69-
sleep: 15
70-
force: true
71-
tags: true
72-
unprotect_reviews: true
73-
74-
- name: Get tagged versions
75-
run: echo "PREVIOUS_VERSION=$(git tag -l --sort -version:refname | sed -n 2p)" >> $GITHUB_ENV
76-
77-
- name: Create release-specific changelog
78-
uses: CharMixer/auto-changelog-action@v1
79-
with:
80-
token: ${{ secrets.GITHUB_TOKEN }}
81-
release_branch: ${{ env.PUBLISH_UPDATE_BRANCH }}
82-
since_tag: "${{ env.PREVIOUS_VERSION }}"
83-
output: "release_changelog.md"
84-
85-
- name: Append changelog to release body
86-
run: |
87-
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} --jq '.body' > release_body.md
88-
cat release_changelog.md >> release_body.md
89-
gh api /repos/${{ github.repository }}/releases/${{ github.event.release.id }} -X PATCH -F body='@release_body.md'
90-
env:
91-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
92-
93-
- name: Publish package to PyPI
94-
uses: pypa/gh-action-pypi-publish@v1.5.0
95-
with:
96-
user: __token__
97-
password: ${{ secrets.PYPI_TOKEN }}
98-
99-
docs:
100-
name: Deploy release documentation
101-
needs: update-and-publish
102-
runs-on: ubuntu-latest
103-
104-
steps:
105-
- name: Checkout repository
106-
uses: actions/checkout@v3
107-
with:
108-
fetch-depth: 0
109-
ref: ${{ env.PUBLISH_UPDATE_BRANCH }}
110-
111-
- name: Set up Python 3.9
112-
uses: actions/setup-python@v4
113-
with:
114-
python-version: "3.9"
115-
116-
- name: Install Python dependencies
117-
run: |
118-
python -m pip install -U pip
119-
pip install -U setuptools wheel flit
120-
pip install -U -e .[doc]
121-
122-
- name: Set up git user
123-
run: |
124-
git config --global user.name "${{ env.GIT_USER_NAME }}"
125-
git config --global user.email "${{ env.GIT_USER_EMAIL }}"
126-
127-
- name: Deploy documentation
128-
run: |
129-
mike deploy --push --remote origin --branch gh-pages --update-aliases --config-file mkdocs.yml ${GITHUB_REF#refs/tags/v} stable
130-
mike deploy --push --remote origin --branch gh-pages --update-aliases --config-file mkdocs.yml latest ${{ env.PUBLISH_UPDATE_BRANCH }}
13+
with:
14+
package_dir: oteapi_optimade
15+
git_username: "TEAM 4.0[bot]"
16+
git_email: "Team4.0@SINTEF.no"
17+
release_branch: main
18+
install_extras: "[dev]"
19+
python_version: "3.9"
20+
update_docs: true
21+
doc_extras: "[doc]"
22+
build_cmd: "pip install -U flit && flit build"
23+
test: true
24+
secrets:
25+
PyPI_token: ${{ secrets.TESTPYPI_TOKEN }}
26+
release_PAT: ${{ secrets.RELEASE_PAT }}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: CI - Check dependencies
2+
3+
on:
4+
schedule:
5+
# At 7:30 every Monday (5:30 UTC)
6+
- cron: "30 5 * * 1"
7+
workflow_dispatch:
8+
9+
jobs:
10+
check-dependencies:
11+
name: Call external workflow
12+
uses: CasperWA/gh-actions/.github/workflows/ci_check_pyproject_dependencies.yml@main
13+
if: github.repository_owner == 'SINTEF'
14+
with:
15+
git_username: "TEAM 4.0[bot]"
16+
git_email: "Team4.0@SINTEF.no"
17+
permanent_dependencies_branch: "ci/dependency-updates"
18+
python_version: "3.9"
19+
install_extras: "[dev]"
20+
pr_labels: "CI/CD"
21+
secrets:
22+
release_PAT: ${{ secrets.RELEASE_PAT }}

0 commit comments

Comments
 (0)