Skip to content
Open
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
28 changes: 15 additions & 13 deletions .github/workflows/buildService.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,35 @@ on:
workflow_dispatch:
pull_request:
paths-ignore: ['*.md']
branches: ['main', 'master']
branches: ['main', 'master', 'update/040']
push:
paths-ignore: ['*.md']
branches: ['main', 'master']
branches: ['main', 'master', 'update/040']

jobs:
BuildPackage:
runs-on: ubuntu-latest
steps:
- name: Prepare StartOS SDK
uses: Start9Labs/sdk@v1
uses: start9labs/sdk@v2

- name: Checkout services repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build the service package
id: build
run: |
git submodule update --init --recursive
start-sdk init
make
PACKAGE_ID=$(yq -oy ".id" manifest.*)
echo "package_id=$PACKAGE_ID" >> $GITHUB_ENV
start-cli init
RUST_LOG=debug RUST_BACKTRACE=1 make
PACKAGE_ID=$(start-cli s9pk inspect *.s9pk manifest | jq -r '.id')
echo "package_id=${PACKAGE_ID}" >> $GITHUB_ENV
printf "\n SHA256SUM: $(sha256sum ${PACKAGE_ID}.s9pk) \n"
shell: bash

# - name: Upload .s9pk
# uses: actions/upload-artifact@v4
# with:
# name: ${{ env.package_id }}.s9pk
# path: ./${{ env.package_id }}.s9pk
- name: Upload .s9pk
uses: actions/upload-artifact@v4
with:
name: ${{ env.package_id }}.s9pk
path: ./${{ env.package_id }}.s9pk
52 changes: 32 additions & 20 deletions .github/workflows/releaseService.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,38 +12,49 @@ jobs:
contents: write
steps:
- name: Prepare StartOS SDK
uses: Start9Labs/sdk@v1
uses: start9labs/sdk@v2

- name: Checkout services repository
uses: actions/checkout@v4
with:
submodules: recursive

- name: Build the service package
id: build
env:
S9DEVKEY: ${{ secrets.S9DEVKEY }}
run: |
git submodule update --init --recursive
start-sdk init
make

- name: Setting package ID and title from the manifest
id: package
run: |
echo "package_id=$(yq -oy ".id" manifest.*)" >> $GITHUB_ENV
echo "package_title=$(yq -oy ".title" manifest.*)" >> $GITHUB_ENV
start-cli init
if [[ -n "$S9DEVKEY" ]]; then
echo "Using developer key from secrets to sign the package."
printf '%s' "$S9DEVKEY" > ~/.startos/developer.key.pem
else
echo "Using newly generated developer key to sign the package."
fi
RUST_LOG=debug RUST_BACKTRACE=1 make
sleep 2
MANIFEST_JSON=$(start-cli s9pk inspect *.s9pk manifest)
PACKAGE_ID=$(echo "$MANIFEST_JSON" | jq -r '.id')
PACKAGE_TITLE=$(echo "$MANIFEST_JSON" | jq -r '.title')
echo "package_id=${PACKAGE_ID}" >> $GITHUB_ENV
echo "package_title=${PACKAGE_TITLE}" >> $GITHUB_ENV
printf "\n SHA256SUM: $(sha256sum ${PACKAGE_ID}.s9pk) \n"
shell: bash

- name: Generate sha256 checksum
run: |
PACKAGE_ID=${{ env.package_id }}
sha256sum ${PACKAGE_ID}.s9pk > ${PACKAGE_ID}.s9pk.sha256
sha256sum ${{ env.package_id }}.s9pk > ${{ env.package_id }}.s9pk.sha256
shell: bash

- name: Generate changelog
run: |
PACKAGE_ID=${{ env.package_id }}
echo "## What's Changed" > change-log.txt
yq -oy '.release-notes' manifest.* >> change-log.txt
echo "" >> change-log.txt
RELEASE_NOTES=$(start-cli s9pk inspect *.s9pk manifest | jq -r '.releaseNotes')
echo "${RELEASE_NOTES}" >> change-log.txt
echo "## SHA256 Hash" >> change-log.txt
echo '```' >> change-log.txt
sha256sum ${PACKAGE_ID}.s9pk >> change-log.txt
sha256sum ${{ env.package_id }}.s9pk >> change-log.txt
echo '```' >> change-log.txt
shell: bash

Expand All @@ -60,12 +71,13 @@ jobs:

- name: Publish to Registry
env:
S9USER: ${{ secrets.S9USER }}
S9PASS: ${{ secrets.S9PASS }}
S9DEVKEY: ${{ secrets.S9DEVKEY }}
S9REGISTRY: ${{ secrets.S9REGISTRY }}
run: |
if [[ -z "$S9USER" || -z "$S9PASS" || -z "$S9REGISTRY" ]]; then
echo "Publish skipped: missing registry credentials."
if [[ -z "$S9DEVKEY" || -z "$S9REGISTRY" ]]; then
echo "Publish skipped: One or both of S9DEVKEY and S9REGISTRY secrets are not set."
else
start-sdk publish https://$S9USER:$S9PASS@$S9REGISTRY ${{ env.package_id }}.s9pk
echo "Publishing package to registry..."
start-cli --registry https://$S9REGISTRY registry package add ${{ env.package_id }}.s9pk ${{ github.server_url }}/${{ github.repository }}/releases/download/${{ github.ref_name }}/${{ env.package_id }}.s9pk
fi
shell: bash
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ riderModule.iml
.idea
*.s9pk
.vscode/
.DS_Store
scripts/*.js
docker-images
node_modules
javascript/*
ncc-cache
14 changes: 2 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# QEMU crashes when building arm64 container, so we use this pattern to create a multi-platform build:
# https://devblogs.microsoft.com/dotnet/improving-multiplatform-container-support/
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:9.0-alpine AS build

# implicitly set by docker build
ARG TARGETARCH
Expand All @@ -25,18 +25,8 @@ RUN \
dotnet publish -a $TARGETARCH --no-restore -c Release -o out

# start from aspnet runtime
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine

# install nginx and yq
RUN \
apk update && \
apk add --no-cache nginx yq && \
rm -rf \
/tmp/* \
/var/cache/apk/* \
/var/tmp/*
FROM mcr.microsoft.com/dotnet/aspnet:9.0-alpine

WORKDIR /app

COPY --chmod=755 ./docker_entrypoint.sh /app/docker_entrypoint.sh
COPY --from=build /app/PushTX/out /app
100 changes: 46 additions & 54 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,63 +1,55 @@
PKG_ID := $(shell yq e ".id" manifest.yaml)
PKG_VERSION := $(shell yq e ".version" manifest.yaml)
TS_FILES := $(shell find ./scripts -name \*.ts)
SOURCES := $(shell find ./src ! -path "*/obj/*" ! -path "*/bin/*" ! -path "*/node_modules/*")
PACKAGE_ID := $(shell grep -o "id: '[^']*'" startos/manifest.ts | sed "s/id: '\([^']*\)'/\1/")
INGREDIENTS := $(shell start-cli s9pk list-ingredients 2> /dev/null)

.PHONY: all clean install check-deps check-init ingredients x86 arm

.DELETE_ON_ERROR:

all: verify
all: ${PACKAGE_ID}.s9pk
@echo " Done!"
@echo " Filesize:$(shell du -h $(PACKAGE_ID).s9pk) is ready"

check-deps:
@if ! command -v start-cli > /dev/null; then \
echo "Error: start-cli not found. Please install it first."; \
exit 1; \
fi
@if ! command -v npm > /dev/null; then \
echo "Error: npm (Node Package Manager) not found. Please install Node.js and npm."; \
exit 1; \
fi

arm:
# this is not a typo, when building arm, remove the x86_64 image so it doesn't get packed by start-sdk
@rm -f docker-images/x86_64.tar
@ARCH=aarch64 $(MAKE)
check-init:
@if [ ! -f ~/.startos/developer.key.pem ]; then \
start-cli init; \
fi

x86:
# this is not a typo, when building x86, remove the aarch64 image so it doesn't get packed by start-sdk
@rm -f docker-images/aarch64.tar
@ARCH=x86_64 $(MAKE)
ingredients: $(INGREDIENTS)
@echo "Re-evaluating ingredients..."

verify: $(PKG_ID).s9pk
@start-sdk verify s9pk $(PKG_ID).s9pk
@echo " Done!"
@echo " Filesize: $(shell du -h $(PKG_ID).s9pk) is ready"
${PACKAGE_ID}.s9pk: $(INGREDIENTS) | check-deps check-init
@$(MAKE) --no-print-directory ingredients
start-cli s9pk pack

javascript/index.js: $(shell git ls-files startos) tsconfig.json node_modules package.json
npm run build

assets:
mkdir -p assets

node_modules: package-lock.json
npm ci

install:
@if [ ! -f ~/.embassy/config.yaml ]; then echo "You must define \"host: http://server-name.local\" in ~/.embassy/config.yaml config file first."; exit 1; fi
@echo "\nInstalling to $$(grep -v '^#' ~/.embassy/config.yaml | cut -d'/' -f3) ...\n"
@[ -f $(PKG_ID).s9pk ] || ( $(MAKE) && echo "\nInstalling to $$(grep -v '^#' ~/.embassy/config.yaml | cut -d'/' -f3) ...\n" )
@start-cli package install $(PKG_ID).s9pk
package-lock.json: package.json
npm i

clean:
rm -rf docker-images
rm -f $(PKG_ID).s9pk
rm -f scripts/*.js

scripts/embassy.js: $(TS_FILES)
deno bundle scripts/embassy.ts scripts/embassy.js

docker-images/aarch64.tar: manifest.yaml Dockerfile docker_entrypoint.sh $(SOURCES)
ifeq ($(ARCH),x86_64)
else
mkdir -p docker-images
docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) \
--platform=linux/arm64 -o type=docker,dest=docker-images/aarch64.tar .
endif

docker-images/x86_64.tar: manifest.yaml Dockerfile docker_entrypoint.sh $(SOURCES)
ifeq ($(ARCH),aarch64)
else
mkdir -p docker-images
docker buildx build --tag start9/$(PKG_ID)/main:$(PKG_VERSION) \
--platform=linux/amd64 -o type=docker,dest=docker-images/x86_64.tar .
endif

$(PKG_ID).s9pk: manifest.yaml instructions.md icon.png LICENSE scripts/embassy.js docker-images/aarch64.tar docker-images/x86_64.tar
ifeq ($(ARCH),aarch64)
@echo "start-sdk: Preparing aarch64 package ..."
else ifeq ($(ARCH),x86_64)
@echo "start-sdk: Preparing x86_64 package ..."
else
@echo "start-sdk: Preparing Universal Package ..."
endif
@start-sdk pack
rm -rf ${PACKAGE_ID}.s9pk
rm -rf javascript
rm -rf node_modules

install: ${PACKAGE_ID}.s9pk
@if [ ! -f ~/.startos/config.yaml ]; then echo "You must define \"host: http://server-name.local\" in ~/.startos/config.yaml config file first."; exit 1; fi
@echo "\nInstalling to $$(grep -v '^#' ~/.startos/config.yaml | cut -d'/' -f3) ...\n"
@[ -f $(PACKAGE_ID).s9pk ] || ( $(MAKE) && echo "\nInstalling to $$(grep -v '^#' ~/.startos/config.yaml | cut -d'/' -f3) ...\n" )
@start-cli package install -s $(PACKAGE_ID).s9pk
60 changes: 0 additions & 60 deletions docker_entrypoint.sh

This file was deleted.

Loading