diff --git a/.gitea/workflows/release.yaml b/.gitea/workflows/release.yaml deleted file mode 100644 index c53ef70..0000000 --- a/.gitea/workflows/release.yaml +++ /dev/null @@ -1,68 +0,0 @@ -name: Backend Actions -run-name: ${{ gitea.actor }} is running backend actions -on: [push] -# push: -# tags: -# - 'v[0-9]+\.[0-9]+\.[0-9]+' - -jobs: - package: - runs-on: rust-latest - depends-on: ["check-tag"] - steps: - - uses: actions/checkout@v4 - - name: Check for Tag - run: ./check-for-tag.sh - - - name: Create Output Directory - if: ${{ steps.check_tag.outputs.release_tag != '' }} - run: mkdir package - - name: Setup Node - if: ${{ steps.check_tag.outputs.release_tag != '' }} - uses: actions/setup-node@v4 - with: - node-version: '24' - - name: Load Cache - if: ${{ steps.check_tag.outputs.release_tag != '' }} - uses: actions/cache@v4 - with: - path: | - ~/.cargo/registry - ~/.cargo/git - backend/target - ui/node_modules - key: ${{ runner.os }}-package-${{ hashFiles('backend/Cargo.lock') }}-${{ hashFiles('ui/package-lock.json') }} - - - name: Install UI Dependencies - if: ${{ steps.check_tag.outputs.release_tag != '' }} - working-directory: ui - run: npm ci - - name: Build UI - if: ${{ steps.check_tag.outputs.release_tag != '' }} - working-directory: ui - run: npm run build - - name: Copy Output - if: ${{ steps.check_tag.outputs.release_tag != '' }} - run: cp -rv ui/.output package/ui - - - - name: Build Backend - if: ${{ steps.check_tag.outputs.release_tag != '' }} - working-directory: backend - run: cargo build --release --locked - - name: Copy Binary - if: ${{ steps.check_tag.outputs.release_tag != '' }} - run: cp -v backend/target/release/nuchat package/ - - - name: Package Output - if: ${{ steps.check_tag.outputs.release_tag != '' }} - run: tar -cf - package | zstd -19 -T0 -o package.tar.zst - - - name: Upload Package - if: ${{ steps.check_tag.outputs.release_tag != '' }} - run: |- - curl -X PUT \ - -H 'Authorization: token ${{ secrets.PACKAGE_API_KEY }}' \ - --upload-file package.tar.zst \ - "https://git.molloy.xyz/api/packages/fergus-molloy/generic/nuchat/${{ $RELEASE_TAG }}/nuchat.tar.zst" - diff --git a/check-for-tag.sh b/check-for-tag.sh deleted file mode 100755 index e8f21f9..0000000 --- a/check-for-tag.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env bash - -TAGS="$(git tag --points-at HEAD)" -echo "Found tags $TAGS" -if [ -n "$TAGS" ]; then - TAG=$(echo "$TAGS" | grep -E '^v[0-9]+.[0-9]+.[0-9]+$' | sort -V | tail -1) - echo "Found release tag $TAG" - echo "release_tag=$TAG" >> "$GITHUB_OUTPUTS" -else - echo "No release tag found" -fi diff --git a/package.sh b/package.sh deleted file mode 100755 index 5c10a9e..0000000 --- a/package.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/usr/bin/env bash - -mkdir package - -pushd backend -cargo build --release -cp -v target/release/nuchat ../package/ -popd - -pushd ui -pnpm run build -cp -rv .output ../package/ui -popd - -tar -cf - package/ | zstd -19 -T0 -o package.tar.zst - diff --git a/scripts/environ.sh b/scripts/environ.sh new file mode 100644 index 0000000..d3a7809 --- /dev/null +++ b/scripts/environ.sh @@ -0,0 +1,36 @@ +#!/usr/bin/env bash + +function check_tags() { + TAGS="$(git tag --points-at HEAD)" + if [ -n "$TAGS" ]; then + TAG=$(echo "$TAGS" | grep -E '^v[0-9]+.[0-9]+.[0-9]+$' | sort -V | tail -1) + else + echo "No release tag found" + return 1 + fi +} + +function package() { + PACKAGE_DIR="${PACKAGE_DIR:-package}" + mkdir "$PACKAGE_DIR" > /dev/null 2>&1 + + pushd backend + cargo build --release + cp -v target/release/nuchat ../package/ + popd + + pushd ui + npm ci + npm run build + cp -rv .output ../package/ui + popd + + + OUT_FILE="${OUT_FILE:-package.tar.zst}" + if [ -f "$OUT_FILE" ]; then + rm "$OUT_FILE" > /dev/null 2>&1 + fi + + tar -cf - package/ | zstd -19 -T0 -o "${OUT_DIR}${OUT_FILE}" +} + diff --git a/scripts/release.sh b/scripts/release.sh new file mode 100755 index 0000000..ef3d2f9 --- /dev/null +++ b/scripts/release.sh @@ -0,0 +1,25 @@ +#!/usr/bin/env bash + +. ./scripts/environ.sh + +check_tags +if [ -n "$TAG" ]; then + echo "Found tag $TAG" + RELEASE_VERSION=$(echo "$TAG" | sed 's/v//') + echo "Releasing $RELEASE_VERSION" + echo "" +else + exit 1 +fi + +package + +if [ ! -f package.tar.zst ]; then + echo "failed to generate package" + exit 1 +fi + +echo "curl -X PUT \ + -H \"Authroization: token $GITEA_TOKEN\" \ + --upload-file \"$OUT_DIR$OUT_FILE\" \ + \"https://git.molloy.xyz/api/packages/fergus-molloy/generic/$RELEASE_VERSION/nuchat.tar.zst\"" diff --git a/tags b/tags deleted file mode 100644 index bf5b101..0000000 --- a/tags +++ /dev/null @@ -1,5 +0,0 @@ -v0.0.1 -v0.0.2 -test -v0.0.2_asdf -