86 lines
2.6 KiB
YAML
86 lines
2.6 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- "v*"
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "20"
|
|
cache: "npm"
|
|
|
|
- name: Install dependencies
|
|
run: npm ci
|
|
|
|
- name: Build
|
|
run: npm run build
|
|
|
|
- name: Get version
|
|
id: version
|
|
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
|
|
|
|
- name: Create release and upload assets
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
VERSION="${{ steps.version.outputs.version }}"
|
|
TAG="${GITHUB_REF#refs/tags/}"
|
|
REPO="${GITHUB_REPOSITORY}"
|
|
SERVER_URL="${GITHUB_SERVER_URL}"
|
|
API_URL="${SERVER_URL}/api/v1"
|
|
|
|
# Create the release
|
|
RELEASE=$(curl -s -X POST "${API_URL}/repos/${REPO}/releases" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{
|
|
\"tag_name\": \"${TAG}\",
|
|
\"name\": \"${TAG}\",
|
|
\"body\": \"Release ${TAG}\",
|
|
\"draft\": false,
|
|
\"prerelease\": false
|
|
}")
|
|
|
|
RELEASE_ID=$(echo "${RELEASE}" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
|
|
|
|
if [ -z "${RELEASE_ID}" ]; then
|
|
echo "Failed to create release. Response: ${RELEASE}"
|
|
exit 1
|
|
fi
|
|
|
|
echo "Created release ID: ${RELEASE_ID}"
|
|
|
|
# Upload all XPI files
|
|
for XPI in .scaffold/build/*.xpi; do
|
|
[ -f "${XPI}" ] || continue
|
|
FILENAME=$(basename "${XPI}")
|
|
echo "Uploading ${FILENAME}..."
|
|
curl -s -X POST "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/octet-stream" \
|
|
--data-binary "@${XPI}"
|
|
done
|
|
|
|
# Upload update manifests if present
|
|
for JSON in .scaffold/build/update.json .scaffold/build/update-beta.json; do
|
|
[ -f "${JSON}" ] || continue
|
|
FILENAME=$(basename "${JSON}")
|
|
echo "Uploading ${FILENAME}..."
|
|
curl -s -X POST "${API_URL}/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${FILENAME}" \
|
|
-H "Authorization: token ${GITEA_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
--data-binary "@${JSON}"
|
|
done
|
|
|
|
echo "Release ${TAG} published successfully."
|