diff --git a/.forgejo/workflows/release.yml b/.forgejo/workflows/release.yml new file mode 100644 index 0000000..107c9de --- /dev/null +++ b/.forgejo/workflows/release.yml @@ -0,0 +1,84 @@ +name: Release Build + +on: + push: + tags: + - 'v*' + branches: + - ci-test + +jobs: + test-and-build: + runs-on: ubuntu-latest + steps: + - name: Setup SSH + run: | + mkdir ~/.ssh + chmod 700 ~/.ssh + echo "${{ secrets.ALTAIR_SSH_KEY }}" > ~/.ssh/id_ed25519 + chmod 600 ~/.ssh/id_ed25519 + ssh-keyscan -p 999 tehga.me >> ~/.ssh/known_hosts + ssh-keyscan -p 999 doradus.tehga.me >> ~/.ssh/known_hosts + + - name: Checkout + run: git clone --depth 1 ssh://gitea@tehga.me:999/wasp/quicknotes.git --branch main --single-branch /workdir + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: '1.24' + cache: true + + - name: Setup Bun + uses: oven-sh/setup-bun@v1 + with: + bun-version: latest + + - name: Install Playwright Browsers + working-directory: /workdir/frontend + run: bun test:install + + - name: Install golangci-lint + run: | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.55.2 + golangci-lint --version + + - name: Run Pre-commit Checks + working-directory: /workdir + run: | + chmod +x scripts/pre-commit.sh + ./scripts/pre-commit.sh + + - name: Optimize Frontend Build + working-directory: /workdir/frontend + run: | + bun install + NODE_ENV=production bun run build + + - name: Build Backend (Release Mode) + working-directory: /workdir + run: | + go build -ldflags="-s -w" -o notes-app + + - name: Package Release + working-directory: /workdir + run: | + mkdir -p release + cp notes-app release/ + cp -r frontend/build release/frontend/ + cp -r static release/ + tar czf quicknotes.tar.gz release/ + + - name: Create Release + if: startsWith(github.ref, 'refs/tags/') + uses: softprops/action-gh-release@v1 + with: + files: /workdir/quicknotes.tar.gz + draft: false + prerelease: false + + - name: Upload Build Artifact + uses: actions/upload-artifact@v4 + with: + name: quicknotes + path: /workdir/quicknotes.tar.gz diff --git a/build.sh b/build.sh index a5d2886..157b223 100755 --- a/build.sh +++ b/build.sh @@ -1,12 +1,24 @@ #!/bin/bash -set -e +set -euo pipefail + +# Check if we're in production mode +PROD_MODE=${NODE_ENV:-development} +GO_FLAGS="" + +if [ "$PROD_MODE" = "production" ]; then + echo "Building in production mode..." + GO_FLAGS="-ldflags=-s -w" +fi # Build frontend +cd frontend +bun install bun run build +cd .. # Copy static assets mkdir -p build/css cp static/css/bulma.min.css build/css/ # Build backend -go build -o notes-app +go build $GO_FLAGS -o notes-app