on: push: branches: - main env: NIX_CONFIG: experimental-features = nix-command flakes jobs: deploy-and-package: runs-on: nixos steps: - name: Install tools run: nix profile add nixpkgs#nodejs_24 nixpkgs#pnpm nixpkgs#rsync nixpkgs#jq nixpkgs#gnused - name: Check out repo uses: https://data.forgejo.org/actions/checkout@v4 - name: Install dependencies run: pnpm install --frozen-lockfile - name: Build and package run: | pnpm pack pnpm --filter @methanium/ui-showcase build - name: Deploy run: rsync -a --delete apps/showcase/dist/ /var/lib/www/methanium-ui/ - name: Create release and upload package env: TOKEN: ${{ forgejo.token }} API: ${{ forgejo.api_url }} REPO: ${{ forgejo.repository }} SHA: ${{ forgejo.sha }} run: | set -eu TAG="$(node -p "require('./package.json').version")" PACKAGE="methanium-ui.tgz" test -f "$PACKAGE" HTTP_STATUS=$(curl -s -w "%{http_code}" -o release_out.json -H "Authorization: token $TOKEN" "$API/repos/$REPO/releases/tags/$TAG") if [ "$HTTP_STATUS" = "200" ]; then echo "Release $TAG already exists." RELEASE_ID="$(jq -r .id release_out.json)" else echo "Creating release for $TAG" RELEASE_JSON="$(curl -f -sS -X POST "$API/repos/$REPO/releases" \ -H "Authorization: token $TOKEN" \ -H "Content-Type: application/json" \ -d "$(jq -n \ --arg tag "$TAG" \ --arg target "$SHA" \ '{ tag_name: $tag, name: $tag, body: "This is an automated release.", target_commitish: $target, draft: false, prerelease: false }')")" RELEASE_ID="$(echo "$RELEASE_JSON" | jq -r .id)" fi curl -fsS -X POST "$API/repos/$REPO/releases/$RELEASE_ID/assets?name=$PACKAGE" \ -H "Authorization: token $TOKEN" \ -F "attachment=@$PACKAGE"