fix(ci): map FORGEJO_RELEASE_TOKEN via env: block
All checks were successful
Build and Release Ody Agent / build (push) Successful in 11s

This commit is contained in:
gitadmin 2026-04-24 02:57:42 +00:00
parent b9d32c2adb
commit e815debecc

View file

@ -14,6 +14,9 @@ on:
jobs: jobs:
build: build:
runs-on: ubuntu-host runs-on: ubuntu-host
env:
FORGEJO_RELEASE_TOKEN: ${{ secrets.FORGEJO_RELEASE_TOKEN }}
GOPATH: /usr/local/go
steps: steps:
- name: Prepare workspace - name: Prepare workspace
run: | run: |
@ -39,33 +42,34 @@ jobs:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build \ GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build \
-ldflags "-s -w -X main.defaultServer=https://425.today" \ -ldflags "-s -w -X main.defaultServer=https://425.today" \
-o /tmp/ody-build/dist/ody-agent-linux . -o /tmp/ody-build/dist/ody-agent-linux .
echo "--- Built artifacts ---" echo "--- Artifacts ---"
ls -lh /tmp/ody-build/dist/ ls -lh /tmp/ody-build/dist/
- name: Publish Forgejo release - name: Publish Forgejo release
run: | run: |
export PATH="/usr/local/go/bin:$PATH"
FORGEJO_URL="https://git.wellspr.ing" FORGEJO_URL="https://git.wellspr.ing"
REPO="wellspring/ody-agent" REPO="wellspring/ody-agent"
if [ "$GITHUB_EVENT_NAME" = "push" ]; then if [ -n "$GITHUB_REF" ] && echo "$GITHUB_REF" | grep -q '^refs/tags/'; then
VERSION="${GITHUB_REF#refs/tags/}" VERSION="${GITHUB_REF#refs/tags/}"
else else
VERSION="v1.0.1" VERSION="v1.0.1"
fi fi
echo "Publishing release: $VERSION" echo "Publishing release: $VERSION"
echo "Token present: $([ -n "$FORGEJO_RELEASE_TOKEN" ] && echo yes || echo NO)"
EXISTING_ID=$(curl -sf "$FORGEJO_URL/api/v1/repos/$REPO/releases/tags/$VERSION" \ EXISTING_ID=$(curl -sf "$FORGEJO_URL/api/v1/repos/$REPO/releases/tags/$VERSION" \
-H "Authorization: token $FORGEJO_RELEASE_TOKEN" 2>/dev/null \ -H "Authorization: token $FORGEJO_RELEASE_TOKEN" 2>/dev/null \
| python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('id',''))" 2>/dev/null || echo "") | python3 -c "import sys,json; d=json.load(sys.stdin); print(d.get('id',''))" 2>/dev/null || echo "")
if [ -n "$EXISTING_ID" ]; then if [ -n "$EXISTING_ID" ]; then
curl -sf -X DELETE "$FORGEJO_URL/api/v1/repos/$REPO/releases/$EXISTING_ID" \ curl -sf -X DELETE "$FORGEJO_URL/api/v1/repos/$REPO/releases/$EXISTING_ID" \
-H "Authorization: token $FORGEJO_RELEASE_TOKEN" -H "Authorization: token $FORGEJO_RELEASE_TOKEN" && echo "Deleted old release $EXISTING_ID"
echo "Deleted old release $EXISTING_ID"
fi fi
RELEASE=$(curl -sf -X POST "$FORGEJO_URL/api/v1/repos/$REPO/releases" \ RELEASE=$(curl -sf -X POST "$FORGEJO_URL/api/v1/repos/$REPO/releases" \
-H "Authorization: token $FORGEJO_RELEASE_TOKEN" \ -H "Authorization: token $FORGEJO_RELEASE_TOKEN" \
-H "Content-Type: application/json" \ -H "Content-Type: application/json" \
-d "{\"tag_name\":\"$VERSION\",\"name\":\"Ody Agent $VERSION\",\"body\":\"Desktop agent for WellSpr.ing merchants. Connects your local machine to your 425.today merchant inbox.\",\"draft\":false}") -d "{\"tag_name\":\"$VERSION\",\"name\":\"Ody Agent $VERSION\",\"body\":\"Desktop agent for WellSpr.ing merchants.\",\"draft\":false}")
RELEASE_ID=$(echo "$RELEASE" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])") RELEASE_ID=$(echo "$RELEASE" | python3 -c "import sys,json; print(json.load(sys.stdin)['id'])")
echo "Created release ID: $RELEASE_ID" echo "Release ID: $RELEASE_ID"
for f in /tmp/ody-build/dist/*; do for f in /tmp/ody-build/dist/*; do
FNAME=$(basename "$f") FNAME=$(basename "$f")
echo "Uploading $FNAME..." echo "Uploading $FNAME..."
@ -74,6 +78,6 @@ jobs:
-H "Authorization: token $FORGEJO_RELEASE_TOKEN" \ -H "Authorization: token $FORGEJO_RELEASE_TOKEN" \
-H "Content-Type: application/octet-stream" \ -H "Content-Type: application/octet-stream" \
--data-binary "@$f" --data-binary "@$f"
echo "$FNAME done." echo "$FNAME uploaded."
done done
echo "Release live: $FORGEJO_URL/$REPO/releases/tag/$VERSION" echo "Done: $FORGEJO_URL/$REPO/releases/tag/$VERSION"