(feat): merge workflows
Some checks failed
/ deploy-and-package (push) Failing after 1s

This commit is contained in:
Alois 2026-07-26 15:23:14 +02:00
commit 378c60c30e
Signed by: alois
SSH key fingerprint: SHA256:GBzT2DXvAuGV9XIV5W3WrzVpjU54FThmxHXdbz95J24
2 changed files with 51 additions and 100 deletions

View file

@ -7,23 +7,63 @@ env:
NIX_CONFIG: experimental-features = nix-command flakes NIX_CONFIG: experimental-features = nix-command flakes
jobs: jobs:
deploy: deploy-and-package:
runs-on: nixos runs-on: nixos
steps: steps:
- name: Install node & pnpm
run: nix profile add nixpkgs#nodejs_24 nixpkgs#pnpm
- name: Check out repo - name: Check out repo
uses: https://data.forgejo.org/actions/checkout@v4 uses: https://data.forgejo.org/actions/checkout@v4
- name: Install dependencies - name: Install tools and dependencies
run: pnpm install --frozen-lockfile run: |
nix profile add nixpkgs#nodejs_24 nixpkgs#pnpm nixpkgs#rsync nixpkgs#jq nixpkgs#gnused
pnpm install --frozen-lockfile
- name: Build - name: Build and package
run: pnpm run build:all run: |
pnpm pack
- name: Install rsync pnpm --filter @methanium/ui-showcase build
run: nix profile add nixpkgs#rsync
- name: Deploy - name: Deploy
run: rsync -a --delete apps/showcase/dist/ /var/lib/www/methanium-ui/ 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"

View file

@ -1,89 +0,0 @@
on:
push:
branches:
- main
env:
NIX_CONFIG: experimental-features = nix-command flakes
jobs:
package:
runs-on: nixos
steps:
- name: Install node & pnpm
run: nix profile add nixpkgs#nodejs_24 nixpkgs#pnpm
- name: Check out repo
uses: https://data.forgejo.org/actions/checkout@v4
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Install sed & jq
run: nix profile add nixpkgs#gnused nixpkgs#jq
- name: Pack package
run: pnpm pack
- name: Read release metadata
id: version
run: |
set -eu
VERSION="$(node -p "require('./package.json').version")"
SHORT_SHA="$(git rev-parse --short=7 HEAD)"
TAG="$VERSION"
PRERELEASE="false"
PACKAGE="methanium-ui.tgz"
test -f "$PACKAGE"
echo "version=$VERSION" >> "$FORGEJO_OUTPUT"
echo "tag=$TAG" >> "$FORGEJO_OUTPUT"
echo "title=$TAG" >> "$FORGEJO_OUTPUT"
echo "prerelease=$PRERELEASE" >> "$FORGEJO_OUTPUT"
echo "package=$PACKAGE" >> "$FORGEJO_OUTPUT"
- name: Create release and upload package
env:
TOKEN: ${{ forgejo.token }}
API: ${{ forgejo.api_url }}
REPO: ${{ forgejo.repository }}
SHA: ${{ forgejo.sha }}
TAG: ${{ steps.version.outputs.tag }}
TITLE: ${{ steps.version.outputs.title }}
PRERELEASE: ${{ steps.version.outputs.prerelease }}
PACKAGE: ${{ steps.version.outputs.package }}
run: |
set -eu
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 name "$TITLE" \
--arg body "This is an automated release." \
--arg target "$SHA" \
--argjson prerelease "$PRERELEASE" \
'{
tag_name: $tag,
name: $name,
body: $body,
target_commitish: $target,
draft: false,
prerelease: $prerelease
}')")"
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"