Skip to content

Commit a679cd3

Browse files
committed
release workflows
1 parent 4561cee commit a679cd3

8 files changed

Lines changed: 255 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,49 @@ permissions:
1111
checks: read
1212

1313
jobs:
14+
docker_build:
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
fetch-tags: true
22+
23+
- name: Set up Docker Buildx
24+
uses: docker/setup-buildx-action@v3
25+
26+
- name: Log in to Docker Hub
27+
uses: docker/login-action@v3
28+
with:
29+
username: ${{ secrets.DOCKER_HUB_USERNAME }}
30+
password: ${{ secrets.DOCKER_HUB_TOKEN }}
31+
32+
- name: Extract version info
33+
run: |
34+
if [ "${{ github.event_name }}" = "push" ]; then
35+
TAG="${GITHUB_REF#refs/tags/}"
36+
echo "VERSION=${TAG#v}" >> "$GITHUB_ENV"
37+
echo "GIT_TAG=${TAG}" >> "$GITHUB_ENV"
38+
else
39+
TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "latest")
40+
echo "VERSION=${TAG#v}" >> "$GITHUB_ENV"
41+
echo "GIT_TAG=${TAG}" >> "$GITHUB_ENV"
42+
fi
43+
echo "COMMIT_SHA=$(git rev-parse --short HEAD)" >> "$GITHUB_ENV"
44+
45+
- name: Build and push Docker image
46+
uses: docker/build-push-action@v6
47+
with:
48+
context: .
49+
platforms: linux/amd64
50+
push: true
51+
tags: |
52+
docker.io/docspringcom/rack-gateway:${{ env.COMMIT_SHA }}
53+
docker.io/docspringcom/rack-gateway:latest
54+
cache-from: type=gha
55+
cache-to: type=gha,mode=max
56+
1457
release_build:
1558
runs-on: ubuntu-latest
1659
steps:

CLAUDE.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,45 @@ See component-specific CLAUDE.md files for detailed implementation information:
513513

514514
See [docs/CONFIGURATION.md](docs/CONFIGURATION.md) for complete environment variable reference.
515515

516+
## Version Management
517+
518+
**Single Source of Truth**: The project version is stored in `web/package.json`.
519+
520+
**Releasing a new version:**
521+
522+
1. Bump the version in `web/package.json`:
523+
```bash
524+
./scripts/bump-version.sh patch # or minor, major
525+
```
526+
527+
2. Commit the version bump:
528+
```bash
529+
git commit -am "chore: bump version to v1.0.1"
530+
```
531+
532+
3. Create a git tag:
533+
```bash
534+
./scripts/create-release-tags.sh
535+
```
536+
537+
4. Push the tag to trigger GitHub Actions release:
538+
```bash
539+
git push origin v1.0.0
540+
# or push all tags:
541+
git push --tags
542+
```
543+
544+
The GitHub Actions release workflow (`.github/workflows/release.yml`) automatically:
545+
- Builds the Docker image for linux/amd64
546+
- Pushes to `docker.io/docspringcom/rack-gateway` with both commit SHA and `latest` tags
547+
- Creates a GitHub release with binaries and checksums
548+
549+
**Deployment:**
550+
551+
After the release workflow completes:
552+
1. Update `convox.yml` to use the new image tag: `image: docker.io/docspringcom/rack-gateway:${COMMIT_SHA}`
553+
2. Run `convox deploy` to deploy to the rack
554+
516555
## Code Structure
517556

518557
```

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# syntax=docker/dockerfile:1
2-
FROM oven/bun:1.3.1-alpine AS webbuild
2+
FROM oven/bun:1.3.2-alpine AS webbuild
33

44
WORKDIR /app/web
55

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,38 @@ DocSpring, Inc. may be able to provide basic paid support for Rack Gateway. Cont
450450

451451
If your support needs are more complex, please consider using the official Convox Console. Convox provides both a hosted console and an enterprise license for on-premise deployments. See the [Convox](https://convox.com) website for more information.
452452

453+
## Releasing
454+
455+
**Version Management**: The project version is stored in `web/package.json`.
456+
457+
To create a new release:
458+
459+
```bash
460+
# 1. Bump the version
461+
./scripts/bump-version.sh patch # or minor, major
462+
463+
# 2. Commit the version bump
464+
git commit -am "chore: bump version to v1.0.1"
465+
466+
# 3. Create and push the release tag
467+
./scripts/create-release-tags.sh
468+
git push origin v1.0.1 # or: git push --tags
469+
```
470+
471+
The GitHub Actions release workflow automatically:
472+
- Builds the Docker image for linux/amd64
473+
- Pushes to `docker.io/docspringcom/rack-gateway` with commit SHA and `latest` tags
474+
- Creates a GitHub release with binaries and checksums
475+
476+
After the release completes, update your deployment:
477+
478+
```bash
479+
# Update convox.yml to use the new image tag
480+
# image: docker.io/docspringcom/rack-gateway:${COMMIT_SHA}
481+
482+
convox deploy
483+
```
484+
453485
## Deployment
454486

455487
See [DEPLOY.md](./docs/DEPLOY.md) for a production-ready deployment guide, environment configuration, persistence, and a minimal `convox.yml` example.

scripts/build-and-push.sh

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,10 @@ echo "Image: ${IMAGE_NAME}"
1212
echo "Commit: ${COMMIT_SHA}"
1313

1414
# Build for amd64 (linux/amd64)
15-
docker buildx build \
16-
--platform linux/amd64 \
15+
# Use DOCKER_DEFAULT_PLATFORM to ensure amd64 build
16+
DOCKER_DEFAULT_PLATFORM=linux/amd64 docker build \
1717
--tag "${IMAGE_NAME}:${COMMIT_SHA}" \
1818
--tag "${IMAGE_NAME}:latest" \
19-
--load \
2019
.
2120

2221
echo ""

scripts/bump-version.sh

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Colors for output
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
8+
BLUE='\033[0;34m'
9+
NC='\033[0m' # No Color
10+
11+
# Function to show usage
12+
usage() {
13+
echo "Usage: $0 {major|minor|patch}"
14+
echo ""
15+
echo "Bump types:"
16+
echo " major - Bump major version (1.0.0 -> 2.0.0)"
17+
echo " minor - Bump minor version (1.0.0 -> 1.1.0)"
18+
echo " patch - Bump patch version (1.0.0 -> 1.0.1)"
19+
exit 1
20+
}
21+
22+
# Function to bump semantic version
23+
bump_version() {
24+
local version=$1
25+
local bump_type=$2
26+
27+
# Parse version
28+
IFS='.' read -r major minor patch <<< "$version"
29+
30+
case "$bump_type" in
31+
major)
32+
major=$((major + 1))
33+
minor=0
34+
patch=0
35+
;;
36+
minor)
37+
minor=$((minor + 1))
38+
patch=0
39+
;;
40+
patch)
41+
patch=$((patch + 1))
42+
;;
43+
esac
44+
45+
echo "${major}.${minor}.${patch}"
46+
}
47+
48+
# Function to get current version from package.json
49+
get_version() {
50+
jq -r '.version' web/package.json
51+
}
52+
53+
# Function to update version in package.json
54+
update_version() {
55+
local new_version=$1
56+
echo -e "${BLUE}Updating version to v${new_version}...${NC}"
57+
58+
cd web
59+
# Update package.json using jq
60+
jq ".version = \"${new_version}\"" package.json > package.json.tmp
61+
mv package.json.tmp package.json
62+
63+
# Update lockfile
64+
bun install
65+
cd ..
66+
67+
echo -e "${GREEN}✓ Version updated to v${new_version}${NC}"
68+
}
69+
70+
# Check arguments
71+
if [ $# -ne 1 ]; then
72+
usage
73+
fi
74+
75+
BUMP_TYPE=$1
76+
77+
# Validate bump type
78+
if [[ ! "$BUMP_TYPE" =~ ^(major|minor|patch)$ ]]; then
79+
echo -e "${RED}Error: Invalid bump type: $BUMP_TYPE${NC}"
80+
usage
81+
fi
82+
83+
# Get current version and calculate new version
84+
current_version=$(get_version)
85+
new_version=$(bump_version "$current_version" "$BUMP_TYPE")
86+
87+
echo -e "${YELLOW}Version: ${current_version} -> ${new_version}${NC}"
88+
update_version "$new_version"
89+
90+
echo ""
91+
echo -e "${GREEN}Version bump complete!${NC}"
92+
echo ""
93+
echo "Next steps:"
94+
echo "1. Review the changes: git diff"
95+
echo "2. Commit: git commit -am \"chore: bump version to v${new_version}\""
96+
echo "3. Create release tag: ./scripts/create-release-tags.sh"
97+
echo "4. Push: git push && git push --tags"

scripts/create-release-tags.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
set -e
3+
4+
# Colors for output
5+
RED='\033[0;31m'
6+
GREEN='\033[0;32m'
7+
YELLOW='\033[1;33m'
8+
NC='\033[0m' # No Color
9+
10+
# Get the version from web/package.json
11+
VERSION=$(jq -r '.version' web/package.json)
12+
13+
if [ -z "$VERSION" ] || [ "$VERSION" = "null" ]; then
14+
echo -e "${RED}Error: Could not read version from web/package.json${NC}"
15+
exit 1
16+
fi
17+
18+
echo -e "${GREEN}Current version: ${VERSION}${NC}"
19+
echo ""
20+
21+
# Create tag name
22+
TAG="v${VERSION}"
23+
24+
# Check if tag already exists
25+
if git rev-parse "$TAG" >/dev/null 2>&1; then
26+
echo -e "${YELLOW}Tag ${TAG} already exists${NC}"
27+
exit 0
28+
fi
29+
30+
echo -e "${GREEN}Creating tag: ${TAG}${NC}"
31+
git tag -a "$TAG" -m "Release ${TAG}"
32+
33+
echo ""
34+
echo -e "${GREEN}Tag created successfully!${NC}"
35+
echo ""
36+
echo -e "${YELLOW}To push the tag to remote, run:${NC}"
37+
echo -e " git push origin ${TAG}"
38+
echo ""
39+
echo -e "${YELLOW}Or push all tags:${NC}"
40+
echo -e " git push --tags"

web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "web",
33
"private": true,
4-
"version": "0.0.0",
4+
"version": "0.0.3",
55
"type": "module",
66
"packageManager": "bun@1.3.1",
77
"scripts": {

0 commit comments

Comments
 (0)