Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 138 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,138 @@
name: Release Pipeline

on:
push:
branches:
- main
- rc
- beta
- alpha
tags:
- "v*.*.*" # Final releases
- "v*.*.*-*" # Pre-release tags (alpha, beta, rc, etc.)

jobs:
semantic-release:
name: Semantic Release
runs-on: ubuntu-latest
outputs:
release_tag: ${{ steps.get_tag.outputs.tag }}
release_upload_url: ${{ steps.get_release.outputs.release_upload_url }}
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0 # Full history is required for proper commit analysis

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Create minimal package.json for semantic-release
run: |
if [ ! -f package.json ]; then
echo '{}' > package.json
fi

- name: Install semantic-release and plugins
run: |
npm install semantic-release \
@semantic-release/commit-analyzer \
@semantic-release/release-notes-generator \
@semantic-release/changelog \
@semantic-release/npm \
@semantic-release/github \
@semantic-release/git

- name: Run semantic-release
id: semantic
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: npx semantic-release || echo "No release created"

- name: Get release tag
id: get_tag
run: |
# Use the tag from GITHUB_REF (if present) or extract from semantic-release output
tag=${GITHUB_REF##*/}
echo "Using tag: $tag"
echo "tag=$tag" >> $GITHUB_OUTPUT

- name: Get release upload URL
id: get_release
run: |
tag=${GITHUB_REF##*/}
echo "Retrieving release for tag: $tag"
# Retrieve the release's upload URL without stripping the placeholder
url=$(gh release view "$tag" --json uploadUrl --jq .uploadUrl)
echo "Upload URL: $url"
echo "release_upload_url=${url}" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}

build-and-release:
name: Build and Release CLI
needs: semantic-release
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, darwin, windows]
goarch: [amd64]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: "1.24.0"

- name: Run tests
run: go test ./...

- name: Build CLI binary
working-directory: cmd/sail
run: |
mkdir -p dist
GOOS=${{ matrix.goos }} GOARCH=${{ matrix.goarch }} \
go build -ldflags "-X 'github.com/SailfinIO/sail/cmd/sail/version.Version=${{ needs.semantic-release.outputs.release_tag }}'" \
-o dist/sail-${{ matrix.goos }}-${{ matrix.goarch }} .

- name: Package CLI binary (Linux/macOS)
if: matrix.goos != 'windows'
run: |
tar -czf sail-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz -C cmd/sail/dist sail-${{ matrix.goos }}-${{ matrix.goarch }}

- name: Package CLI binary (Windows)
if: matrix.goos == 'windows'
run: |
zip -j sail-${{ matrix.goos }}-${{ matrix.goarch }}.zip cmd/sail/dist/sail-${{ matrix.goos }}-${{ matrix.goarch }}

- name: List files
run: ls -l

- name: Upload CLI Binary (Linux/macOS)
if: matrix.goos != 'windows'
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
upload_url: ${{ needs.semantic-release.outputs.release_upload_url }}
asset_path: sail-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
asset_name: sail-${{ matrix.goos }}-${{ matrix.goarch }}.tar.gz
asset_content_type: application/octet-stream

- name: Upload CLI Binary (Windows)
if: matrix.goos == 'windows'
uses: actions/upload-release-asset@v1.0.2
env:
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }}
with:
upload_url: ${{ needs.semantic-release.outputs.release_upload_url }}
asset_path: sail-${{ matrix.goos }}-${{ matrix.goarch }}.zip
asset_name: sail-${{ matrix.goos }}-${{ matrix.goarch }}.zip
asset_content_type: application/octet-stream
46 changes: 46 additions & 0 deletions .github/workflows/semantic-release.yml.old
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Semantic Release

on:
push:
branches:
- main
- rc
- beta
- alpha

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN }}
fetch-depth: 0 # Full history is required for proper commit analysis

- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"

- name: Create minimal package.json for semantic-release
run: |
# Create a minimal package.json if one doesn't exist
if [ ! -f package.json ]; then
echo '{}' > package.json
fi

- name: Install semantic-release and plugins
run: |
npm install semantic-release \
@semantic-release/commit-analyzer \
@semantic-release/release-notes-generator \
@semantic-release/changelog \
@semantic-release/npm \
@semantic-release/github \
@semantic-release/git

- name: Run semantic-release
env:
GH_TOKEN: ${{ secrets.GH_TOKEN }}
run: npx semantic-release
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@ go.work.sum

# env file
.env

# for semantic-release
node_modules/
16 changes: 16 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# .goreleaser.yml
project_name: sail
builds:
- main: ./cmd/sail/cli
ldflags: >
-X 'github.com/SailfinIO/sail/cmd/sail/version.Version={{.Version}}'
archives:
- format: tar.gz
name_template: "{{ .ProjectName }}_{{ .Os }}_{{ .Arch }}"
checksum:
name_template: "{{ .ProjectName }}_checksums.txt"
release:
prerelease: "{{ semver.Prerelease }}"
github:
owner: SailfinIO
name: sail
47 changes: 47 additions & 0 deletions .releaser.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"branches": [
"main",
"rc",
{
"name": "beta",
"prerelease": true
},
{
"name": "alpha",
"prerelease": true
}
],
"plugins": [
[
"@semantic-release/commit-analyzer",
{
"preset": "conventionalcommits",
"releaseRules": [
{ "type": "feat", "release": "minor" },
{ "type": "fix", "release": "patch" },
{ "type": "chore", "release": false },
{ "type": "docs", "release": false },
{ "type": "refactor", "release": "patch" },
{ "type": "style", "release": false },
{ "type": "test", "release": false }
],
"parserOpts": {
"noteKeywords": ["BREAKING CHANGE", "BREAKING CHANGES"]
}
}
],
"@semantic-release/release-notes-generator",
"@semantic-release/changelog",
"@semantic-release/npm",
"@semantic-release/github",
[
"@semantic-release/git",
{
"message": "chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}",
"assets": ["package.json", "CHANGELOG.md"],
"push": true
}
]
],
"preset": "conventionalcommits"
}
20 changes: 1 addition & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Sail is a modular, NestJS-inspired framework for Go. It provides a lightweight a

## Project Structure

- **cmd/sail/**: Entry point for the demo application or CLI.
- **cmd/sail/cli**: Entry point for the `sail` CLI.
- **internal/**: Core implementation details including dependency injection, module lifecycle, HTTP server, routing, and logging.
- **pkg/sail/**: Public API for bootstrapping and interacting with the framework.
- **pkg/middleware/**: Optional middleware implementations (e.g., CORS).
Expand All @@ -24,21 +24,3 @@ Sail is a modular, NestJS-inspired framework for Go. It provides a lightweight a
```bash
go mod init github.com/SailfinIO/sail
```

Breakdown of Key Components
cmd/
This directory contains the entry point for your framework. For instance, cmd/sail/main.go A CLI tool that initializes and runs the framework.
internal/core/
container.go: Implements a basic dependency injection (DI) container. This helps in managing service instances and wiring up dependencies between modules.
module.go: Defines how modules are registered, initialized, and run. Similar to NestJS modules, this can encapsulate a feature’s controllers, providers, and configuration.
internal/server/
http.go: Wraps Go’s built-in net/http package to create a simple HTTP server.
router.go: Handles route registration and middleware integration. This module could evolve to support more complex routing features.
internal/logger/
A simple logging abstraction that wraps the standard library’s log package (or any minimal logging solution) to provide consistency across the framework.
pkg/sail/
This is your public-facing API. It exposes the core functionalities of your framework (like bootstrapping an application, module registration, and configuration) so that developers can easily import and use Sail in their own projects.
pkg/middleware/
Here you can provide optional middleware (for instance, for CORS, security, or request logging). This is kept separate from the core to maintain modularity.
go.mod & README.md
The go.mod file initializes your project as a Go module. The README.md serves as the landing page for users to understand how to get started with Sail.
Loading
Loading