Skip to content

Commit 0b877e6

Browse files
committed
ci wip
1 parent d2933ed commit 0b877e6

File tree

3 files changed

+162
-0
lines changed

3 files changed

+162
-0
lines changed

.github/workflows/release.yml

+143
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
name: Release
2+
on:
3+
push:
4+
branches:
5+
- master
6+
- v[0-9]+.[0-9]+.[0-9]+*
7+
release:
8+
types:
9+
- published
10+
jobs:
11+
prep:
12+
name: Prepare release
13+
runs-on: ubuntu-latest
14+
if: ${{ github.event_name == 'push' && github.ref_name != 'master' }}
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
defaults:
19+
run:
20+
shell: bash
21+
steps:
22+
23+
- name: Checkout release branch
24+
uses: actions/checkout@v3
25+
with:
26+
fetch-depth: 0
27+
28+
- name: Setup Python
29+
uses: actions/setup-python@v4
30+
with:
31+
python-version: 3.x
32+
cache: 'pip'
33+
cache-dependency-path: pyproject.toml
34+
35+
- name: Install Python dependencies
36+
run: |
37+
pip install --upgrade pip
38+
pip install build twine
39+
pip install .
40+
pip install ".[lint, test]"
41+
42+
- name: Update version
43+
id: version
44+
run: |
45+
ref="${{ github.ref_name }}"
46+
version="${ref#"v"}"
47+
python scripts/update_version.py -v "$version"
48+
python -c "import xattree; print('Version: ', xattree.__version__)"
49+
echo "version=$version" >> $GITHUB_OUTPUT
50+
51+
- name: Push release branch
52+
env:
53+
GITHUB_TOKEN: ${{ github.token }}
54+
run: |
55+
ver="${{ steps.version.outputs.version }}"
56+
57+
# commit and push changes
58+
git config core.sharedRepository true
59+
git config user.name "github-actions[bot]"
60+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
61+
git add -A
62+
git commit -m "ci(release): set version to ${{ steps.version.outputs.version }}"
63+
git push origin "${{ github.ref_name }}"
64+
65+
title="Release $ver"
66+
body='
67+
# Release '$ver'
68+
69+
The release can be approved by merging this pull request into `master`. This will trigger a job to publish the release to PyPI.
70+
'
71+
gh pr create -B "master" -H "${{ github.ref_name }}" --title "$title" --draft --body "$body"
72+
73+
release:
74+
name: Draft release
75+
# runs only when changes are merged to master
76+
if: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
77+
runs-on: ubuntu-latest
78+
permissions:
79+
contents: write
80+
pull-requests: write
81+
steps:
82+
83+
- name: Checkout repo
84+
uses: actions/checkout@v3
85+
with:
86+
ref: master
87+
88+
- name: Draft release
89+
env:
90+
GITHUB_TOKEN: ${{ github.token }}
91+
run: |
92+
version=$(cat version.txt)
93+
title="xattree $version"
94+
gh release create "$version" \
95+
--target master \
96+
--title "$title" \
97+
--draft \
98+
--latest
99+
100+
publish:
101+
name: Publish package
102+
# runs only after release is published (manually promoted from draft)
103+
if: ${{ github.event_name == 'release' }}
104+
runs-on: ubuntu-22.04
105+
permissions:
106+
contents: write
107+
pull-requests: write
108+
id-token: write # mandatory for trusted publishing
109+
environment: # requires a 'release' environment in repo settings
110+
name: release
111+
url: https://pypi.org/p/xattree
112+
steps:
113+
114+
- name: Checkout master branch
115+
uses: actions/checkout@v3
116+
with:
117+
ref: master
118+
119+
- name: Setup Python
120+
uses: actions/setup-python@v4
121+
with:
122+
python-version: 3.x
123+
124+
- name: Install Python dependencies
125+
run: |
126+
pip install --upgrade pip
127+
pip install build twine
128+
pip install .
129+
130+
- name: Build package
131+
run: python -m build
132+
133+
- name: Check package
134+
run: twine check --strict dist/*
135+
136+
- name: Upload package
137+
uses: actions/upload-artifact@v3
138+
with:
139+
name: dist
140+
path: dist
141+
142+
- name: Publish to PyPI
143+
uses: pypa/gh-action-pypi-publish@release/v1

.readthedocs.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
version: 2
2+
build:
3+
os: "ubuntu-24.04"
4+
tools:
5+
python: "3.13"
6+
sphinx:
7+
configuration: docs/conf.py
8+
formats:
9+
- pdf
10+
python:
11+
install:
12+
- method: pip
13+
path: .
14+
extra_requirements:
15+
- docs

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# xattree
22

3+
[![CI](https://github.com/modflowpy/xattree/actions/workflows/ci.yml/badge.svg)](https://github.com/modflowpy/xattree/actions/workflows/ci.yml)
4+
[![Docs](https://readthedocs.org/projects/xattree/badge/?version=latest)](https://xattree.readthedocs.io/en/latest/?badge=latest)
5+
[![GitHub contributors](https://img.shields.io/github/contributors/modflowpy/xattree)](https://img.shields.io/github/contributors/modflowpy/xattree)
6+
37
`attrs` + `xarray.DataTree` = `xattree`
48

59
"exa-tree", or "cat tree" if you like.

0 commit comments

Comments
 (0)