Skip to content
Merged

Dev #145

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.

Large diffs are not rendered by default.

74 changes: 0 additions & 74 deletions .github.bak/ISSUE_TEMPLATE/bug.yaml

This file was deleted.

38 changes: 38 additions & 0 deletions .github/actions/setup-rust/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: setup-rust
description: Setup Rust toolchain and Cargo cache for NodeGet
inputs:
components:
description: Rust components to install
required: false
default: ""
targets:
description: Rust targets to install
required: false
default: ""
cache-shared-key:
description: Shared cache key for Swatinem/rust-cache
required: false
default: ""
cache-targets:
description: Whether to cache target directories
required: false
default: "true"
cache-on-failure:
description: Whether to save cache when a job fails
required: false
default: "true"
runs:
using: composite
steps:
- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: ${{ inputs.components }}
targets: ${{ inputs.targets }}

- name: Restore Cargo cache
uses: Swatinem/rust-cache@v2
with:
shared-key: ${{ inputs.cache-shared-key }}
cache-targets: ${{ inputs.cache-targets }}
cache-on-failure: ${{ inputs.cache-on-failure }}
243 changes: 243 additions & 0 deletions .github/workflows/release-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,243 @@
name: release-server

on:
workflow_dispatch:
inputs:
release_tag:
description: "Release tag to publish, for example v0.3.7. Leave empty for artifact-only manual builds."
required: false
type: string
publish_release:
description: "Create/update the GitHub Release and Docker image. Requires release_tag."
required: false
default: false
type: boolean

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'push' && github.ref_name || inputs.release_tag || github.run_id }}
cancel-in-progress: false

permissions:
contents: read

env:
CARGO_TERM_COLOR: always

jobs:
prepare:
name: Prepare release
runs-on: ubuntu-latest
outputs:
publish: ${{ steps.release.outputs.publish }}
tag: ${{ steps.release.outputs.tag }}
steps:
- name: Resolve release mode
id: release
shell: bash
run: |
publish="false"
tag=""

# push tag 触发 → 自动发布;手动触发 → 读取 inputs
if [[ "${GITHUB_EVENT_NAME}" == "push" ]]; then
publish="true"
tag="${GITHUB_REF_NAME}"
else
publish="${{ inputs.publish_release }}"
tag="${{ inputs.release_tag }}"
fi

# 发布时校验 tag 格式:v + 语义版本,允许 pre-release 后缀如 -rc1, +build123
if [[ "${publish}" == "true" ]]; then
if [[ ! "${tag}" =~ ^v[0-9]+(\.[0-9]+)*([-+][0-9A-Za-z.-]+)?$ ]]; then
echo "release_tag must look like v0.3.7 when publishing" >&2
exit 1
fi
fi

echo "publish=${publish}" >> "${GITHUB_OUTPUT}"
echo "tag=${tag}" >> "${GITHUB_OUTPUT}"

build-linux:
name: Build - ${{ matrix.platform.release_for }}
needs: prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
platform:
- release_for: linux_x86_64_musl
target: x86_64-unknown-linux-musl
binary_name: nodeget-server-linux-x86_64-musl
- release_for: linux_x86_64_gnu
target: x86_64-unknown-linux-gnu
binary_name: nodeget-server-linux-x86_64-gnu
- release_for: linux_arm_gnueabi
target: arm-unknown-linux-gnueabi
binary_name: nodeget-server-linux-arm-gnueabi
- release_for: linux_arm_gnueabihf
target: arm-unknown-linux-gnueabihf
binary_name: nodeget-server-linux-arm-gnueabihf
- release_for: linux_aarch64_gnu
target: aarch64-unknown-linux-gnu
binary_name: nodeget-server-linux-aarch64-gnu
- release_for: linux_aarch64_musl
target: aarch64-unknown-linux-musl
binary_name: nodeget-server-linux-aarch64-musl
- release_for: linux_armv7_gnueabi
target: armv7-unknown-linux-gnueabi
binary_name: nodeget-server-linux-armv7-gnueabi
- release_for: linux_armv7_gnueabihf
target: armv7-unknown-linux-gnueabihf
binary_name: nodeget-server-linux-armv7-gnueabihf
- release_for: linux_armv7_musleabi
target: armv7-unknown-linux-musleabi
binary_name: nodeget-server-linux-armv7-musleabi
- release_for: linux_armv7_musleabihf
target: armv7-unknown-linux-musleabihf
binary_name: nodeget-server-linux-armv7-musleabihf
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
cache-shared-key: release-linux-${{ matrix.platform.target }}

- name: Install cross
env:
CROSS_VERSION: v0.2.5
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p "${HOME}/.local/bin"
gh release download "${CROSS_VERSION}" \
--repo cross-rs/cross \
--pattern cross-x86_64-unknown-linux-gnu.tar.gz \
-O - \
| tar -xz -C "${HOME}/.local/bin"
echo "${HOME}/.local/bin" >> "${GITHUB_PATH}"

- name: Build binary
run: cross build --package nodeget-server --target ${{ matrix.platform.target }} --profile minimal --jobs 32
env:
CROSS_NO_WARNINGS: 0

- name: Compress binary
run: upx -9 ./target/${{ matrix.platform.target }}/minimal/nodeget-server

- name: Rename binary
run: cp target/${{ matrix.platform.target }}/minimal/nodeget-server target/${{ matrix.platform.target }}/minimal/${{ matrix.platform.binary_name }}

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: server-${{ matrix.platform.target }}
path: target/${{ matrix.platform.target }}/minimal/${{ matrix.platform.binary_name }}
if-no-files-found: error
retention-days: 14

build-windows:
name: Build - ${{ matrix.platform.release_for }}
needs: prepare
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
platform:
- release_for: windows_x86_64
target: x86_64-pc-windows-msvc
binary_name: nodeget-server-windows-x86_64.exe
- release_for: windows_aarch64
target: aarch64-pc-windows-msvc
binary_name: nodeget-server-windows-aarch64.exe
steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
targets: ${{ matrix.platform.target }}
cache-shared-key: release-windows-${{ matrix.platform.target }}

- name: Build binary
run: cross build --package nodeget-server --target ${{ matrix.platform.target }} --profile minimal --jobs 32
env:
CROSS_NO_WARNINGS: 0

- name: Rename binary
run: copy target\${{ matrix.platform.target }}\minimal\nodeget-server.exe target\${{ matrix.platform.target }}\minimal\${{ matrix.platform.binary_name }}

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: server-${{ matrix.platform.target }}
path: target/${{ matrix.platform.target }}/minimal/${{ matrix.platform.binary_name }}
if-no-files-found: error
retention-days: 14

build-macos:
name: Build - ${{ matrix.platform.release_for }}
needs: prepare
runs-on: macos-latest
strategy:
fail-fast: false
matrix:
platform:
- release_for: macos_aarch64
target: aarch64-apple-darwin
binary_name: nodeget-server-macos-aarch64

steps:
- name: Checkout
uses: actions/checkout@v6

- name: Setup Rust
uses: ./.github/actions/setup-rust
with:
targets: ${{ matrix.platform.target }}
cache-shared-key: release-macos-${{ matrix.platform.target }}

- name: Build binary
run: cargo build --package nodeget-server --target ${{ matrix.platform.target }} --profile minimal --jobs 32
env:
CROSS_NO_WARNINGS: 0

- name: Rename binary
run: cp target/${{ matrix.platform.target }}/minimal/nodeget-server target/${{ matrix.platform.target }}/minimal/${{ matrix.platform.binary_name }}

- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: server-${{ matrix.platform.target }}
path: target/${{ matrix.platform.target }}/minimal/${{ matrix.platform.binary_name }}
if-no-files-found: error
retention-days: 14

publish-release:
name: Publish GitHub Release
needs:
- prepare
- build-linux
- build-windows
- build-macos
if: needs.prepare.outputs.publish == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download artifacts
uses: actions/download-artifact@v8
with:
pattern: *
path: dist
merge-multiple: true

- name: Upload release assets
uses: softprops/action-gh-release@v3
with:
tag_name: ${{ needs.prepare.outputs.tag }}
name: NodeGet ${{ needs.prepare.outputs.tag }}
make_latest: true
files: dist/*
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ static
rp.md
rustest
nodeget.db*
.claude
.claude
/server/profile.json.gz
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@ ng-migration = { path = "crates/ng-db/migration" }
[profile]
dev = { opt-level = 0, debug = true, debug-assertions = true, overflow-checks = true, lto = false, panic = "unwind", incremental = true, codegen-units = 256, rpath = false }
release = { opt-level = 3, debug = false, debug-assertions = false, overflow-checks = false, lto = false, panic = "unwind", incremental = false, codegen-units = 16, rpath = false }
profiling = { inherits = "release", debug = true }
fastest = { inherits = "dev", opt-level = 0, debug = 0, debug-assertions = true, overflow-checks = true, lto = false, panic = "unwind", incremental = true, codegen-units = 512, rpath = false }
minimal = { inherits = "release", opt-level = "z", lto = true, codegen-units = 1, panic = "abort", debug = false, strip = true, debug-assertions = false, overflow-checks = false }
Loading