Skip to content

Commit 161b89b

Browse files
committed
build: add the release task & workflow
Updated mise tasks: - ✅ Added github-cli tool - Installs gh CLI automatically - ✅ Enhanced release task - Uses gh release create for GitHub release - ✅ Complete automation - Handles tags, GitHub release, and major version updates - ✅ Proper escaping - Handles YAML and JSON in release notes Simplified GitHub workflow: - ✅ Single step - Just calls mise run release - ✅ Passes GITHUB_TOKEN - For gh CLI authentication - ✅ Clean and maintainable - All logic is in mise tasks Benefits: - Local/CI consistency - Same release process everywhere - Tool management - mise handles all dependencies (dprint, bun, gh) - Maintainability - One place to update release logic - Flexibility - Can run releases locally or via GitHub Usage: # Local release mise run release -- v1.2.3 # Or via GitHub workflow # Actions → Release → Run workflow → Enter v1.2.3
1 parent c2d9b4a commit 161b89b

File tree

2 files changed

+114
-1
lines changed

2 files changed

+114
-1
lines changed

.github/workflows/release.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Release
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to release (e.g., v1.2.3)'
8+
required: true
9+
type: string
10+
11+
jobs:
12+
release:
13+
name: Create Release
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: write
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
23+
- name: Setup mise
24+
uses: jdx/mise-action@v2
25+
26+
- name: Create release
27+
run: mise run release -- ${{ inputs.version }}
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.mise.toml

Lines changed: 85 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
[tools]
22
dprint = "latest"
33
bun = "latest"
4+
github-cli = "latest"
45

56
[tasks.format]
67
description = "Format code using dprint"
@@ -18,4 +19,87 @@ run = [
1819

1920
[tasks.ci]
2021
description = "Run all CI checks locally"
21-
alias = "check"
22+
alias = "check"
23+
24+
[tasks.release]
25+
description = "Create a new release with version tag (usage: mise run release -- v1.2.3)"
26+
depends = ["check"]
27+
run = '''
28+
if [ -z "$1" ]; then
29+
echo 'Error: Please provide version (e.g., mise run release -- v1.2.3)'
30+
exit 1
31+
fi
32+
33+
VERSION="$1"
34+
MAJOR_VERSION=$(echo $VERSION | cut -d. -f1)
35+
36+
echo "=== Creating GitHub Action release ==="
37+
echo "Version: $VERSION (major: $MAJOR_VERSION)"
38+
39+
# Ensure we're on main branch and up to date
40+
git checkout main
41+
git pull origin main
42+
43+
# Create and push version tag
44+
echo "Creating tag: $VERSION"
45+
git tag -a "$VERSION" -m "Release $VERSION"
46+
git push origin "$VERSION"
47+
48+
# Create GitHub release using gh CLI
49+
echo "Creating GitHub release"
50+
gh release create "$VERSION" \
51+
--title "Release $VERSION" \
52+
--notes "## Changes
53+
54+
See [CHANGELOG.md](https://github.com/cdviz-dev/send-cdevents/blob/main/CHANGELOG.md) for details.
55+
56+
## Usage
57+
58+
\`\`\`yaml
59+
- name: Send CDEvent
60+
uses: cdviz-dev/send-cdevents@$VERSION
61+
with:
62+
data: |
63+
{
64+
\"context\": {
65+
\"version\": \"0.4.1\",
66+
\"source\": \"github-actions\",
67+
\"type\": \"dev.cdevents.taskrun.started.0.2.0\"
68+
},
69+
\"subject\": {
70+
\"id\": \"\${{ github.run_id }}\",
71+
\"type\": \"taskRun\",
72+
\"content\": {
73+
\"taskName\": \"ci-build\"
74+
}
75+
}
76+
}
77+
url: \"https://your-webhook-endpoint.com/cdevents\"
78+
\`\`\`"
79+
80+
# Update major version tag (e.g., v1)
81+
echo "Updating major version tag: $MAJOR_VERSION"
82+
git tag -f -a "$MAJOR_VERSION" -m "Release $MAJOR_VERSION (latest: $VERSION)"
83+
git push origin "$MAJOR_VERSION" --force
84+
85+
echo "=== Release completed! ==="
86+
echo "✅ Created version tag: $VERSION"
87+
echo "✅ Created GitHub release: $VERSION"
88+
echo "✅ Updated major tag: $MAJOR_VERSION"
89+
echo "📦 GitHub Marketplace will auto-update from the major version tag"
90+
'''
91+
92+
[tasks.release-check]
93+
description = "Check current release status and tags"
94+
depends = ["check"]
95+
run = '''
96+
echo "=== Current Release Status ==="
97+
echo "Latest tags:"
98+
git tag --sort=-version:refname | head -5
99+
100+
echo "Current branch:"
101+
git branch --show-current
102+
103+
echo "Uncommitted changes:"
104+
git status --porcelain || echo "Working tree clean"
105+
'''

0 commit comments

Comments
 (0)