Skip to content

Commit 8da318a

Browse files
authored
Merge pull request #43 from upstat-io/dev
feat(ci): auto-release on PR merge to master
2 parents 20c91d6 + 6c5ceb4 commit 8da318a

2 files changed

Lines changed: 139 additions & 33 deletions

File tree

.github/workflows/auto-release.yml

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
name: Auto Release
2+
3+
# Automatically bump version, tag, and trigger release on every merge to master.
4+
# During alpha, every PR merge gets its own release (alpha.N → alpha.N+1).
5+
6+
on:
7+
push:
8+
branches: [master]
9+
10+
# Queue releases — don't cancel in-progress ones.
11+
# Each merge gets its own version bump, processed sequentially.
12+
concurrency:
13+
group: auto-release
14+
cancel-in-progress: false
15+
16+
jobs:
17+
auto-release:
18+
name: Bump Version & Tag
19+
runs-on: ubuntu-latest
20+
timeout-minutes: 10
21+
22+
# Skip release commits to prevent infinite loop.
23+
# The version bump commit starts with "chore: release v".
24+
if: "!startsWith(github.event.head_commit.message, 'chore: release v')"
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
token: ${{ secrets.ORILANG_RELEASE_TOKEN }}
31+
fetch-depth: 0
32+
ref: master
33+
34+
- name: Configure git
35+
run: |
36+
git config user.name "github-actions[bot]"
37+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
38+
39+
- name: Install Rust
40+
uses: dtolnay/rust-toolchain@stable
41+
42+
- name: Determine version
43+
id: version
44+
run: |
45+
CURRENT=$(grep -E '^version\s*=' Cargo.toml | head -1 | sed 's/.*=\s*"\([^"]*\)".*/\1/')
46+
echo "current=$CURRENT" >> $GITHUB_OUTPUT
47+
48+
if git rev-parse "refs/tags/v$CURRENT" &>/dev/null; then
49+
# Tag exists — auto-increment
50+
echo "Tag v$CURRENT already exists, auto-incrementing..."
51+
echo "bumped=true" >> $GITHUB_OUTPUT
52+
else
53+
# Tag doesn't exist — version was set manually in a PR, or first release
54+
echo "Tag v$CURRENT does not exist, using current version as-is"
55+
echo "bumped=false" >> $GITHUB_OUTPUT
56+
echo "new_version=$CURRENT" >> $GITHUB_OUTPUT
57+
fi
58+
59+
- name: Bump version
60+
if: steps.version.outputs.bumped == 'true'
61+
run: ./scripts/release.sh --yes
62+
63+
- name: Read new version
64+
id: new_version
65+
run: |
66+
VERSION=$(grep -E '^version\s*=' Cargo.toml | head -1 | sed 's/.*=\s*"\([^"]*\)".*/\1/')
67+
echo "version=$VERSION" >> $GITHUB_OUTPUT
68+
echo "New version: $VERSION"
69+
70+
- name: Regenerate lockfiles
71+
if: steps.version.outputs.bumped == 'true'
72+
run: |
73+
cargo generate-lockfile
74+
cargo generate-lockfile --manifest-path compiler/ori_llvm/Cargo.toml
75+
cargo generate-lockfile --manifest-path compiler/ori_rt/Cargo.toml
76+
cargo generate-lockfile --manifest-path tools/ori-lsp/Cargo.toml
77+
cargo generate-lockfile --manifest-path website/playground-wasm/Cargo.toml
78+
79+
- name: Commit version bump
80+
if: steps.version.outputs.bumped == 'true'
81+
run: |
82+
git add -A
83+
git commit -m "chore: release v${{ steps.new_version.outputs.version }}"
84+
85+
- name: Tag and push
86+
run: |
87+
git tag "v${{ steps.new_version.outputs.version }}"
88+
git push origin master --tags

scripts/release.sh

Lines changed: 51 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ BOLD='\033[1m'
2525
NC='\033[0m' # No Color
2626

2727
usage() {
28-
echo "Usage: $0 [version]"
28+
echo "Usage: $0 [OPTIONS] [version]"
29+
echo ""
30+
echo "Options:"
31+
echo " -y, --yes Skip interactive confirmation (for CI)"
32+
echo " -h, --help Show this help message"
2933
echo ""
3034
echo "If no version specified, auto-increments the pre-release number:"
3135
echo " 0.1.0-alpha.1 → 0.1.0-alpha.2"
@@ -34,6 +38,7 @@ usage() {
3438
echo ""
3539
echo "Examples:"
3640
echo " $0 # Auto-increment nightly"
41+
echo " $0 --yes # Auto-increment without confirmation (CI)"
3742
echo " $0 0.1.0-beta.1 # Start beta phase"
3843
echo " $0 0.2.0 # Stable release"
3944
echo ""
@@ -90,10 +95,17 @@ update_workspace_version() {
9095
}
9196

9297
main() {
93-
# Handle help flag
94-
if [[ "${1:-}" == "-h" ]] || [[ "${1:-}" == "--help" ]]; then
95-
usage
96-
fi
98+
local auto_confirm=false
99+
local explicit_version=""
100+
101+
while [[ $# -gt 0 ]]; do
102+
case "$1" in
103+
-h|--help) usage ;;
104+
-y|--yes) auto_confirm=true; shift ;;
105+
-*) echo -e "${RED}ERROR${NC}: Unknown option: $1"; usage ;;
106+
*) explicit_version="$1"; shift ;;
107+
esac
108+
done
97109

98110
# Ensure we're on master branch
99111
local current_branch
@@ -116,12 +128,12 @@ main() {
116128

117129
# Determine new version
118130
local new_version
119-
if [[ $# -eq 0 ]]; then
131+
if [[ -z "$explicit_version" ]]; then
120132
# Auto-increment
121133
new_version=$(auto_increment_version "$current_version")
122134
echo -e "${CYAN}Auto-incrementing version...${NC}"
123135
else
124-
new_version="$1"
136+
new_version="$explicit_version"
125137
fi
126138

127139
# Validate
@@ -132,12 +144,14 @@ main() {
132144
echo -e "${BOLD}New version:${NC} $new_version"
133145
echo ""
134146

135-
# Confirm
136-
read -p "Proceed with version bump? [y/N] " -n 1 -r
137-
echo
138-
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
139-
echo "Aborted."
140-
exit 1
147+
# Confirm (skip with --yes)
148+
if ! $auto_confirm; then
149+
read -p "Proceed with version bump? [y/N] " -n 1 -r
150+
echo
151+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
152+
echo "Aborted."
153+
exit 1
154+
fi
141155
fi
142156

143157
echo ""
@@ -148,26 +162,30 @@ main() {
148162
echo "=== Syncing all manifests ==="
149163
"$SCRIPT_DIR/sync-version.sh"
150164

151-
echo ""
152-
echo -e "${CYAN}═══════════════════════════════════════════════════════════${NC}"
153-
echo -e "${CYAN} NEXT STEPS ${NC}"
154-
echo -e "${CYAN}═══════════════════════════════════════════════════════════${NC}"
155-
echo ""
156-
echo "1. Review changes:"
157-
echo " git diff"
158-
echo ""
159-
echo "2. Run full test suite:"
160-
echo " ./test-all"
161-
echo ""
162-
echo "3. Commit and tag:"
163-
echo -e " ${YELLOW}git add -A && git commit -m \"chore: release v$new_version\"${NC}"
164-
echo -e " ${YELLOW}git tag v$new_version${NC}"
165-
echo -e " ${YELLOW}git push origin master --tags${NC}"
166-
echo ""
167-
echo "The release workflow will automatically:"
168-
echo " • Build binaries for Linux, macOS, Windows"
169-
echo " • Create GitHub release (marked as nightly/pre-release)"
170-
echo " • Generate checksums and release notes"
165+
# Show next steps only in interactive mode
166+
if ! $auto_confirm; then
167+
echo ""
168+
echo -e "${CYAN}═══════════════════════════════════════════════════════════${NC}"
169+
echo -e "${CYAN} NEXT STEPS ${NC}"
170+
echo -e "${CYAN}═══════════════════════════════════════════════════════════${NC}"
171+
echo ""
172+
echo "1. Review changes:"
173+
echo " git diff"
174+
echo ""
175+
echo "2. Run full test suite:"
176+
echo " ./test-all"
177+
echo ""
178+
echo "3. Commit and tag:"
179+
echo -e " ${YELLOW}git add -A && git commit -m \"chore: release v$new_version\"${NC}"
180+
echo -e " ${YELLOW}git tag v$new_version${NC}"
181+
echo -e " ${YELLOW}git push origin master --tags${NC}"
182+
echo ""
183+
echo "The release workflow will automatically:"
184+
echo " • Build binaries for Linux, macOS, Windows"
185+
echo " • Create GitHub release (marked as nightly/pre-release)"
186+
echo " • Generate checksums and release notes"
187+
fi
188+
171189
echo ""
172190
echo -e "${GREEN}Version bump complete!${NC}"
173191
}

0 commit comments

Comments
 (0)