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
17 changes: 0 additions & 17 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ name: CI
on:
push:
branches: [main]
tags: ["v*"]
pull_request:
branches: [main]

Expand Down Expand Up @@ -84,19 +83,3 @@ jobs:
with:
name: teslausb-linux-arm64
path: teslausb-linux-arm64

release:
if: startsWith(github.ref, 'refs/tags/v')
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- uses: actions/download-artifact@v4
with:
name: teslausb-linux-arm64

- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: teslausb-linux-arm64
120 changes: 120 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: "Version tag (e.g. v0.3.1)"
required: true
type: string

permissions:
contents: write

jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Validate version format
run: |
if [[ ! "${{ inputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "::error::Version must match vX.Y.Z format (e.g. v0.3.1)"
exit 1
fi

test:
runs-on: ubuntu-latest
needs: validate
permissions:
contents: read
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.mod

- run: go test ./...

build-web:
runs-on: ubuntu-latest
needs: validate
permissions:
contents: read
steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: "20"

- name: Build React frontend
working-directory: web
run: |
npm ci
npm run build

- uses: actions/upload-artifact@v4
with:
name: web-dist
path: web/dist/

build:
runs-on: ubuntu-latest
needs: [test, build-web]
permissions:
contents: read
steps:
- uses: actions/checkout@v4

- uses: actions/setup-go@v5
with:
go-version-file: go.mod
cache: false

- uses: actions/download-artifact@v4
with:
name: web-dist
path: internal/web/static/

- name: Cross-compile for arm64
run: >
GOOS=linux GOARCH=arm64 go build
-ldflags "-X main.version=${{ inputs.version }}"
-o teslausb-linux-arm64
./cmd/teslausb

- uses: actions/upload-artifact@v4
with:
name: teslausb-linux-arm64
path: teslausb-linux-arm64

release:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-tags: true

- uses: actions/download-artifact@v4
with:
name: teslausb-linux-arm64

- name: Create tag
run: |
if git rev-parse "${{ inputs.version }}" >/dev/null 2>&1; then
echo "::error::Tag ${{ inputs.version }} already exists. Delete it first to recreate."
exit 1
fi
git tag ${{ inputs.version }}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if tag exists first for clearer error if re-running after partial failure

Suggested change
git tag ${{ inputs.version }}
if git rev-parse "${{ inputs.version }}" >/dev/null 2>&1; then
echo "::error::Tag ${{ inputs.version }} already exists. Delete it first to recreate."
exit 1
fi
git tag ${{ inputs.version }}

git push origin ${{ inputs.version }}
Comment on lines +112 to +113
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pushing this tag triggers ci.yml (which has on: push: tags: ["v*"]), causing both workflows to build and create releases simultaneously - if intentional as a safety net, this is fine but resource-intensive

Comment on lines +98 to +113
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tag existence check won't work - actions/checkout@v4 doesn't fetch tags by default, so line 106 won't see remote tags and will incorrectly proceed even if tag exists remotely

Suggested change
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
name: teslausb-linux-arm64
- name: Create tag
run: |
if git rev-parse "${{ inputs.version }}" >/dev/null 2>&1; then
echo "::error::Tag ${{ inputs.version }} already exists. Delete it first to recreate."
exit 1
fi
git tag ${{ inputs.version }}
git push origin ${{ inputs.version }}
- uses: actions/checkout@v4
with:
fetch-tags: true
- uses: actions/download-artifact@v4
with:
name: teslausb-linux-arm64
- name: Create tag
run: |
if git rev-parse "${{ inputs.version }}" >/dev/null 2>&1; then
echo "::error::Tag ${{ inputs.version }} already exists. Delete it first to recreate."
exit 1
fi
git tag ${{ inputs.version }}
git push origin ${{ inputs.version }}


- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ inputs.version }}
generate_release_notes: true
files: teslausb-linux-arm64