Skip to content

Commit 7866069

Browse files
authored
Merge pull request #16 from pnstack/copilot/release-default-version
Add automatic release on main branch pushes
2 parents 4436ce2 + ab96419 commit 7866069

2 files changed

Lines changed: 23 additions & 2 deletions

File tree

.github/workflows/release.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ on:
44
push:
55
tags:
66
- 'v*'
7+
branches:
8+
- main
79
workflow_dispatch:
810
inputs:
911
version:
@@ -63,6 +65,17 @@ jobs:
6365
run: |
6466
if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then
6567
echo "VERSION=${{ inputs.version }}" >> $GITHUB_OUTPUT
68+
elif [ "${{ github.ref }}" == "refs/heads/main" ]; then
69+
if [ ! -f package.json ]; then
70+
echo "Error: package.json not found"
71+
exit 1
72+
fi
73+
VERSION="v$(node -p "require('./package.json').version" 2>/dev/null)"
74+
if [ -z "$VERSION" ] || [ "$VERSION" = "v" ] || [ "$VERSION" = "vundefined" ] || [ "$VERSION" = "vnull" ]; then
75+
echo "Error: Unable to extract valid version from package.json"
76+
exit 1
77+
fi
78+
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
6679
else
6780
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
6881
fi
@@ -77,8 +90,9 @@ jobs:
7790

7891
- name: Create Release
7992
uses: softprops/action-gh-release@v1
80-
if: startsWith(github.ref, 'refs/tags/')
93+
if: startsWith(github.ref, 'refs/tags/') || github.ref == 'refs/heads/main'
8194
with:
95+
tag_name: ${{ steps.get_version.outputs.VERSION }}
8296
files: |
8397
release/**/*.exe
8498
release/**/*.dmg

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ This project includes comprehensive CI/CD workflows using GitHub Actions:
123123

124124
- **Release** (`release.yml`) - Automated releases
125125
- Triggers on version tags (e.g., `v1.0.0`)
126+
- Triggers on pushes to main branch (auto-creates release with package.json version)
126127
- Builds for all platforms (Windows, macOS, Linux)
127128
- Creates GitHub releases with binaries
128129
- Manual trigger option available
@@ -140,8 +141,14 @@ This project includes comprehensive CI/CD workflows using GitHub Actions:
140141

141142
### Creating a Release
142143

143-
To create a new release:
144+
Releases are automatically created in two ways:
144145

146+
**1. Automatic release on main branch**
147+
- Every push to the main branch automatically creates a release
148+
- Uses the version from `package.json` (e.g., if package.json has "version": "1.0.0", it creates release v1.0.0)
149+
- Builds and publishes binaries for all platforms
150+
151+
**2. Manual release with version tag**
145152
```bash
146153
# Create and push a version tag
147154
git tag v1.0.0

0 commit comments

Comments
 (0)