Skip to content

Commit 56af87f

Browse files
authored
Merge pull request #36 from USI-FMAA/copilot/fix-35
Add GitHub Actions release workflow for automated releases
2 parents 9a129f2 + dd6ff2f commit 56af87f

File tree

2 files changed

+87
-0
lines changed

2 files changed

+87
-0
lines changed

.github/workflows/release.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Trigger on version tags (v0.1.0, v1.0.0, etc.)
7+
8+
permissions:
9+
contents: write # Required to create releases
10+
11+
jobs:
12+
release:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- name: Checkout repository
17+
uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0 # Fetch full history for tags
20+
21+
- name: Install uv
22+
uses: astral-sh/setup-uv@v5
23+
with:
24+
enable-cache: true
25+
26+
- name: Set up Python
27+
uses: actions/setup-python@v5
28+
with:
29+
python-version-file: "pyproject.toml"
30+
31+
- name: Install dependencies
32+
run: |
33+
uv sync --all-extras --dev
34+
35+
- name: Install GitHub CLI
36+
run: |
37+
type -p curl >/dev/null || (sudo apt update && sudo apt install curl -y)
38+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
39+
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
40+
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
41+
&& sudo apt update \
42+
&& sudo apt install gh -y
43+
44+
- name: Build package
45+
run: |
46+
uv run invoke build
47+
48+
- name: Create GitHub Release and Upload Assets
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
run: |
52+
# Extract tag name
53+
TAG_NAME=${GITHUB_REF#refs/tags/}
54+
echo "Creating release for tag: $TAG_NAME"
55+
56+
# Use the existing gh_release task from tasks.py
57+
uv run invoke gh_release
58+
59+
# Upload built packages to the release
60+
gh release upload "$TAG_NAME" dist/*.whl dist/*.tar.gz --clobber

CONTRIBUTING.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,35 @@ command line to ease recurring operations:
3939
* `invoke check`: Run various code and documentation style checks.
4040
* `invoke docs`: Generate documentation.
4141
* `invoke test`: Run all tests and checks in one swift command.
42+
* `invoke build`: Build the package for distribution.
43+
* `invoke build-release`: Build a release with automatic version bumping and tagging.
44+
* `invoke gh-release`: Create GitHub release using GitHub CLI - automatically detects tag.
4245
* `invoke`: Show available tasks.
4346

47+
## Releases
48+
49+
Releases are automated via GitHub Actions. To create a new release:
50+
51+
1. **Manual Release Process**:
52+
```bash
53+
# Bump version and create tag (patch/minor/major)
54+
invoke build-release --part=patch
55+
56+
# Push tags to trigger automated release
57+
git push origin --tags
58+
```
59+
60+
2. **Automated Release Process**:
61+
- The GitHub Actions workflow (`.github/workflows/release.yml`) automatically triggers on tag pushes
62+
- Builds the package using `uv build`
63+
- Creates a GitHub release with changelog notes using `invoke gh-release`
64+
- Uploads wheel and source distribution as release assets
65+
66+
3. **Release Artifacts**:
67+
- Python wheel (`.whl`)
68+
- Source distribution (`.tar.gz`)
69+
- Automated release notes from changelog
70+
4471
## Bug reports
4572

4673
When [reporting a bug](https://github.com/USI-FMAA/dcs/issues) please include:

0 commit comments

Comments
 (0)