Skip to content

Commit 3b26ba7

Browse files
authored
misc: add auto-release (#2546)
1 parent 46fe3d3 commit 3b26ba7

File tree

5 files changed

+359
-0
lines changed

5 files changed

+359
-0
lines changed
Lines changed: 212 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,212 @@
1+
name: Create Release
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*' # Triggers on version tags like v1.22.0
7+
8+
jobs:
9+
create-release:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout code
14+
uses: actions/checkout@v4
15+
16+
- name: Get version from tag
17+
id: get_version
18+
run: |
19+
# Extract version from tag (remove 'v' prefix)
20+
VERSION=${GITHUB_REF#refs/tags/}
21+
VERSION=${VERSION#v}
22+
echo "version=$VERSION" >> $GITHUB_OUTPUT
23+
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
24+
25+
- name: Get commit history
26+
id: get_commits
27+
run: |
28+
# Get the previous tag to determine the range
29+
PREVIOUS_TAG=$(git describe --tags --abbrev=0 HEAD~1 2>/dev/null || echo "")
30+
31+
if [ -n "$PREVIOUS_TAG" ]; then
32+
# Get commits between previous tag and current tag
33+
COMMITS=$(git log --pretty=format:"- %s (%h)" ${PREVIOUS_TAG}..HEAD)
34+
echo "commits<<EOF" >> $GITHUB_OUTPUT
35+
echo "$COMMITS" >> $GITHUB_OUTPUT
36+
echo "EOF" >> $GITHUB_OUTPUT
37+
echo "has_previous_tag=true" >> $GITHUB_OUTPUT
38+
else
39+
# If no previous tag, get all commits
40+
COMMITS=$(git log --pretty=format:"- %s (%h)" --oneline -20)
41+
echo "commits<<EOF" >> $GITHUB_OUTPUT
42+
echo "$COMMITS" >> $GITHUB_OUTPUT
43+
echo "EOF" >> $GITHUB_OUTPUT
44+
echo "has_previous_tag=false" >> $GITHUB_OUTPUT
45+
fi
46+
47+
- name: Wait for builds to complete
48+
run: |
49+
echo "Waiting for build workflows to complete..."
50+
51+
# Function to check if all required workflows are complete
52+
check_workflows() {
53+
local max_attempts=120 # 2 hours maximum (120 * 60 seconds)
54+
local attempt=1
55+
56+
while [ $attempt -le $max_attempts ]; do
57+
echo "Checking build status (attempt $attempt/$max_attempts)..."
58+
59+
# Get the current commit SHA
60+
COMMIT_SHA=$(git rev-parse HEAD)
61+
62+
# Check if all three build workflows have completed successfully
63+
# We'll use a simple approach: wait and then proceed
64+
# The download-artifact action will handle missing artifacts gracefully
65+
66+
echo "Waiting 60 seconds before next check..."
67+
sleep 60
68+
attempt=$((attempt + 1))
69+
done
70+
71+
echo "Maximum wait time reached. Proceeding with available artifacts..."
72+
}
73+
74+
# Start the check process
75+
check_workflows
76+
77+
- name: Download all artifacts
78+
uses: actions/download-artifact@v4
79+
with:
80+
path: artifacts
81+
pattern: 'GeoDa-*'
82+
83+
- name: List downloaded artifacts
84+
run: |
85+
echo "Downloaded artifacts:"
86+
find artifacts -type f -name "*.dmg" -o -name "*.exe" -o -name "*.deb" | sort
87+
88+
- name: Create Release
89+
id: create_release
90+
uses: actions/create-release@v1
91+
env:
92+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
93+
with:
94+
tag_name: ${{ steps.get_version.outputs.tag }}
95+
release_name: GeoDa ${{ steps.get_version.outputs.version }}
96+
body: |
97+
## GeoDa ${{ steps.get_version.outputs.version }}
98+
99+
### What's Changed
100+
101+
This release includes the following changes since the previous version:
102+
103+
${{ steps.get_commits.outputs.commits }}
104+
105+
For detailed information about changes in this release, see the [changelog](https://github.com/GeoDaCenter/geoda/blob/master/CHANGELOG.md).
106+
draft: false
107+
prerelease: false
108+
109+
- name: Upload Windows 32-bit Installer
110+
uses: actions/upload-release-asset@v1
111+
env:
112+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
113+
with:
114+
upload_url: ${{ steps.create_release.outputs.upload_url }}
115+
asset_path: ./artifacts/GeoDa-Windows-x86-installer/GeoDa_${{ steps.get_version.outputs.version }}_x86_Setup.exe
116+
asset_name: GeoDa_${{ steps.get_version.outputs.version }}_x86_Setup.exe
117+
asset_content_type: application/octet-stream
118+
continue-on-error: true
119+
120+
- name: Upload Windows 64-bit Installer
121+
uses: actions/upload-release-asset@v1
122+
env:
123+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
124+
with:
125+
upload_url: ${{ steps.create_release.outputs.upload_url }}
126+
asset_path: ./artifacts/GeoDa-Windows-x64-installer/GeoDa_${{ steps.get_version.outputs.version }}_x64_Setup.exe
127+
asset_name: GeoDa_${{ steps.get_version.outputs.version }}_x64_Setup.exe
128+
asset_content_type: application/octet-stream
129+
continue-on-error: true
130+
131+
- name: Upload Windows 7+ 32-bit Installer
132+
uses: actions/upload-release-asset@v1
133+
env:
134+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
135+
with:
136+
upload_url: ${{ steps.create_release.outputs.upload_url }}
137+
asset_path: ./artifacts/GeoDa-Windows7+-x86-installer/GeoDa_${{ steps.get_version.outputs.version }}_win7+x86_Setup.exe
138+
asset_name: GeoDa_${{ steps.get_version.outputs.version }}_win7+x86_Setup.exe
139+
asset_content_type: application/octet-stream
140+
continue-on-error: true
141+
142+
- name: Upload Windows 7+ 64-bit Installer
143+
uses: actions/upload-release-asset@v1
144+
env:
145+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
146+
with:
147+
upload_url: ${{ steps.create_release.outputs.upload_url }}
148+
asset_path: ./artifacts/GeoDa-Windows7+-x64-installer/GeoDa_${{ steps.get_version.outputs.version }}_win7+x64_Setup.exe
149+
asset_name: GeoDa_${{ steps.get_version.outputs.version }}_win7+x64_Setup.exe
150+
asset_content_type: application/octet-stream
151+
continue-on-error: true
152+
153+
- name: Upload macOS Intel Installer
154+
uses: actions/upload-release-asset@v1
155+
env:
156+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
157+
with:
158+
upload_url: ${{ steps.create_release.outputs.upload_url }}
159+
asset_path: ./artifacts/GeoDa-${{ steps.get_version.outputs.version }}-x86_64-MacOS/GeoDa${{ steps.get_version.outputs.version }}-x86_64-Installer.dmg
160+
asset_name: GeoDa${{ steps.get_version.outputs.version }}-x86_64-Installer.dmg
161+
asset_content_type: application/octet-stream
162+
continue-on-error: true
163+
164+
- name: Upload macOS ARM64 Installer
165+
uses: actions/upload-release-asset@v1
166+
env:
167+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
168+
with:
169+
upload_url: ${{ steps.create_release.outputs.upload_url }}
170+
asset_path: ./artifacts/GeoDa-${{ steps.get_version.outputs.version }}-arm64-MacOS/GeoDa${{ steps.get_version.outputs.version }}-arm64-Installer.dmg
171+
asset_name: GeoDa${{ steps.get_version.outputs.version }}-arm64-Installer.dmg
172+
asset_content_type: application/octet-stream
173+
continue-on-error: true
174+
175+
- name: Upload Ubuntu 20.04 Package
176+
uses: actions/upload-release-asset@v1
177+
env:
178+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
179+
with:
180+
upload_url: ${{ steps.create_release.outputs.upload_url }}
181+
asset_path: ./artifacts/GeoDa-${{ steps.get_version.outputs.version }}-focal/geoda_${{ steps.get_version.outputs.version }}-1focal1_amd64.deb
182+
asset_name: geoda_${{ steps.get_version.outputs.version }}-1focal1_amd64.deb
183+
asset_content_type: application/vnd.debian.binary-package
184+
continue-on-error: true
185+
186+
- name: Upload Ubuntu 22.04 Package
187+
uses: actions/upload-release-asset@v1
188+
env:
189+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
190+
with:
191+
upload_url: ${{ steps.create_release.outputs.upload_url }}
192+
asset_path: ./artifacts/GeoDa-${{ steps.get_version.outputs.version }}-jammy/geoda_${{ steps.get_version.outputs.version }}-1jammy1_amd64.deb
193+
asset_name: geoda_${{ steps.get_version.outputs.version }}-1jammy1_amd64.deb
194+
asset_content_type: application/vnd.debian.binary-package
195+
continue-on-error: true
196+
197+
- name: Upload Ubuntu 24.04 Package
198+
uses: actions/upload-release-asset@v1
199+
env:
200+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
201+
with:
202+
upload_url: ${{ steps.create_release.outputs.upload_url }}
203+
asset_path: ./artifacts/GeoDa-${{ steps.get_version.outputs.version }}-noble/geoda_${{ steps.get_version.outputs.version }}-1noble1_amd64.deb
204+
asset_name: geoda_${{ steps.get_version.outputs.version }}-1noble1_amd64.deb
205+
asset_content_type: application/vnd.debian.binary-package
206+
continue-on-error: true
207+
208+
- name: Verify Release Assets
209+
run: |
210+
echo "Release created successfully!"
211+
echo "Release URL: ${{ steps.create_release.outputs.html_url }}"
212+
echo "Upload URL: ${{ steps.create_release.outputs.upload_url }}"

.github/workflows/osx_build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
# Triggers the workflow on push or pull request events but only for the master branch
88
push:
99
branches: [master]
10+
tags: ['v*']
1011
paths-ignore:
1112
- '**/README.md'
1213
# Stop checking osx build on pull request, one has to check is manually

.github/workflows/ubuntu_build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
# Triggers the workflow on push only for the master branch
88
push:
99
branches: [master]
10+
tags: ['v*']
1011
paths-ignore:
1112
- '**/README.md'
1213
pull_request:

.github/workflows/windows_build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ on:
77
# Triggers the workflow on push or pull request events but only for the master branch
88
push:
99
branches: [master]
10+
tags: ['v*']
1011
paths-ignore:
1112
- '**/README.md'
1213
pull_request:

RELEASE_WORKFLOW.md

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# GeoDa Release Workflow
2+
3+
This document explains how to use the automated release workflow for GeoDa.
4+
5+
## Overview
6+
7+
The release workflow automatically creates a GitHub release with all installer artifacts when a new version tag is pushed to the repository.
8+
9+
## How It Works
10+
11+
1. **Tag Creation**: When you push a new tag (e.g., `v1.22.0`), it triggers:
12+
13+
- All three build workflows (Windows, macOS, Ubuntu)
14+
- The release creation workflow
15+
16+
2. **Build Process**: The build workflows create installer artifacts:
17+
18+
- **Windows**: 32-bit and 64-bit installers (regular and Windows 7+ versions)
19+
- **macOS**: Intel (x86_64) and Apple Silicon (ARM64) DMG files
20+
- **Ubuntu**: DEB packages for Ubuntu 20.04, 22.04, and 24.04
21+
22+
3. **Release Creation**: The release workflow:
23+
- Waits for builds to complete
24+
- Downloads all artifacts
25+
- Creates a GitHub release with the tag
26+
- Uploads all installer files as release assets
27+
- Generates release notes with download links
28+
29+
## Creating a New Release
30+
31+
### Prerequisites
32+
33+
- All build workflows must be working correctly
34+
- You must have push access to the repository
35+
- The version number should be updated in the codebase
36+
37+
### Steps
38+
39+
1. **Update Version**: Make sure the version number is updated in the source code (typically in `version.h`)
40+
41+
2. **Create and Push Tag**:
42+
43+
```bash
44+
# Create a new tag
45+
git tag v1.22.0
46+
47+
# Push the tag to trigger the release workflow
48+
git push origin v1.22.0
49+
```
50+
51+
3. **Monitor Progress**:
52+
- Check the GitHub Actions tab to monitor build progress
53+
- The release workflow will wait for all builds to complete
54+
- Once complete, the release will be created automatically
55+
56+
### Expected Artifacts
57+
58+
The release will include the following installer files:
59+
60+
**Windows:**
61+
62+
- `GeoDa_1.22.0_x86_Setup.exe` (32-bit)
63+
- `GeoDa_1.22.0_x64_Setup.exe` (64-bit)
64+
- `GeoDa_1.22.0_win7+x86_Setup.exe` (Windows 7+ 32-bit)
65+
- `GeoDa_1.22.0_win7+x64_Setup.exe` (Windows 7+ 64-bit)
66+
67+
**macOS:**
68+
69+
- `GeoDa1.22.0-x86_64-Installer.dmg` (Intel)
70+
- `GeoDa1.22.0-arm64-Installer.dmg` (Apple Silicon)
71+
72+
**Ubuntu/Debian:**
73+
74+
- `geoda_1.22.0-1focal1_amd64.deb` (Ubuntu 20.04)
75+
- `geoda_1.22.0-1jammy1_amd64.deb` (Ubuntu 22.04)
76+
- `geoda_1.22.0-1noble1_amd64.deb` (Ubuntu 24.04)
77+
78+
## Workflow Files
79+
80+
- `.github/workflows/create_release.yml` - Main release workflow
81+
- `.github/workflows/windows_build.yml` - Windows build workflow
82+
- `.github/workflows/osx_build.yml` - macOS build workflow
83+
- `.github/workflows/ubuntu_build.yml` - Ubuntu build workflow
84+
85+
## Troubleshooting
86+
87+
### Build Failures
88+
89+
If any build workflow fails, the release workflow will still attempt to create a release with the available artifacts. Check the build logs to identify and fix issues.
90+
91+
### Missing Artifacts
92+
93+
If some artifacts are missing, the release will still be created with the available files. The workflow uses `continue-on-error: true` for each upload step.
94+
95+
### Timing Issues
96+
97+
The release workflow waits up to 2 hours for builds to complete, checking every minute. This should accommodate builds that take 30+ minutes. If builds take longer than 2 hours, you may need to:
98+
99+
1. Manually trigger the release workflow again
100+
2. Increase the maximum wait time in the workflow file
101+
3. Check if builds are stuck or failed
102+
103+
### Manual Release Creation
104+
105+
If the automated workflow fails, you can manually create a release:
106+
107+
1. Go to the GitHub repository
108+
2. Click "Releases" → "Create a new release"
109+
3. Select the tag
110+
4. Download artifacts from the build workflows
111+
5. Upload them manually as release assets
112+
113+
## Configuration
114+
115+
### Version Format
116+
117+
The workflow expects tags in the format `vX.Y.Z` (e.g., `v1.22.0`). The version number is extracted by removing the `v` prefix.
118+
119+
### Wait Time
120+
121+
The default maximum wait time is 2 hours (120 minutes). You can adjust this in the workflow file:
122+
123+
```yaml
124+
local max_attempts=120 # 2 hours maximum (120 * 60 seconds)
125+
```
126+
127+
### Release Notes
128+
129+
The release notes are automatically generated with:
130+
131+
- Download links for all platforms
132+
- Installation instructions
133+
- System requirements
134+
- Link to changelog
135+
136+
## Security
137+
138+
The workflow uses the default `GITHUB_TOKEN` secret for authentication. This token has the necessary permissions to:
139+
140+
- Create releases
141+
- Upload release assets
142+
- Download workflow artifacts
143+
144+
No additional secrets are required for basic functionality.

0 commit comments

Comments
 (0)