71 lines
1.9 KiB
YAML
71 lines
1.9 KiB
YAML
name: Publish Obsidian plugin
|
|
|
|
on:
|
|
push:
|
|
tags: ["*"]
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
publish-plugin:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup Node.js environment
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: "25.x"
|
|
|
|
- name: Build plugin
|
|
run: |
|
|
cd frontend
|
|
npm ci
|
|
npm run build
|
|
|
|
- name: Setup Rust toolchain
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
toolchain: "1.92.0"
|
|
components: clippy, rustfmt
|
|
|
|
- name: Install cross-compilation tools
|
|
run: |
|
|
apt update
|
|
apt install -y gcc-aarch64-linux-gnu musl-tools gcc-mingw-w64-x86-64 jq
|
|
|
|
- name: Build Linux and Windows binaries
|
|
run: ./scripts/build-sync-server-binaries.sh
|
|
|
|
- name: Create release
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
SERVER_URL: ${{ github.server_url }}
|
|
REPO: ${{ github.repository }}
|
|
run: |
|
|
tag="${GITHUB_REF#refs/tags/}"
|
|
|
|
mkdir -p release
|
|
cp frontend/obsidian-plugin/dist/* release/
|
|
cp sync-server/artifacts/sync-server-* release/
|
|
|
|
# Create draft release via Forgejo API
|
|
RELEASE_ID=$(curl -s -X POST \
|
|
"${SERVER_URL}/api/v1/repos/${REPO}/releases" \
|
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
-H "Content-Type: application/json" \
|
|
-d "{\"tag_name\": \"${tag}\", \"name\": \"${tag}\", \"draft\": true}" \
|
|
| jq -r '.id')
|
|
|
|
# Upload release assets
|
|
for file in release/*; do
|
|
filename=$(basename "$file")
|
|
curl -s -X POST \
|
|
"${SERVER_URL}/api/v1/repos/${REPO}/releases/${RELEASE_ID}/assets?name=${filename}" \
|
|
-H "Authorization: token ${GITHUB_TOKEN}" \
|
|
-F "attachment=@${file}"
|
|
done
|