Skip to content

Commit 34db9f0

Browse files
authored
Merge pull request #25 from sparrowapp-dev/build/selfhost-build
Build/selfhost build
2 parents 13210f0 + 790699e commit 34db9f0

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed
Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
name: Self-host Docker Image
22
on:
3+
push:
4+
branches:
5+
- main
36
workflow_dispatch:
4-
inputs:
5-
image_version:
6-
description: "Docker image version (e.g. 1.2.3)"
7-
required: true
8-
type: string
97

108
permissions:
119
contents: read
@@ -14,13 +12,27 @@ jobs:
1412
build:
1513
runs-on: ubuntu-latest
1614
environment: self-host
17-
env:
18-
DOCKER_IMAGE_VERSION: ${{ inputs.image_version }}
1915

2016
steps:
2117
- name: Checkout
2218
uses: actions/checkout@v4
2319

20+
- name: Read version from package.json
21+
id: version
22+
run: |
23+
if ! command -v jq >/dev/null 2>&1; then
24+
echo "jq not found"; exit 1
25+
fi
26+
V=$(jq -r '.version' package.json)
27+
if [ -z "$V" ] || [ "$V" = "null" ]; then
28+
echo "Version not found in package.json"; exit 1
29+
fi
30+
if ! [[ "$V" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
31+
echo "Version $V is not valid semver (expected X.Y.Z)"; exit 1
32+
fi
33+
echo "full=$V" >> "$GITHUB_OUTPUT"
34+
35+
2436
- name: Set up QEMU
2537
uses: docker/setup-qemu-action@v3
2638

@@ -35,10 +47,11 @@ jobs:
3547

3648
- name: Build and push (multi-arch)
3749
run: |
38-
echo "Building version: ${DOCKER_IMAGE_VERSION}"
50+
set -euo pipefail
51+
VERSION='${{ steps.version.outputs.full }}'
52+
echo "Building image tag: $VERSION"
3953
docker buildx build \
4054
--platform linux/amd64,linux/arm64 \
41-
--build-arg GITHUB_TOKEN=${{ secrets.SPARROW_GITHUB_TOKEN }} \
42-
-t ssparrowapi/sparrow-proxy:self-host-${DOCKER_IMAGE_VERSION} \
43-
-t ssparrowapi/sparrow-proxy:latest \
55+
-t $DOCKER_IMAGE_NAME:$VERSION \
56+
-t sparrowapi/sparrow-proxy:latest \
4457
--push .

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "sparrow-proxy",
3-
"version": "0.0.1",
3+
"version": "2.29.0",
44
"description": "",
55
"author": "",
66
"private": true,

0 commit comments

Comments
 (0)