Skip to content
Open
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
120 changes: 120 additions & 0 deletions .github/workflows/sea-orm-cli-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
name: sea-orm-cli release

on:
push:
tags:
- "sea-orm-cli@*"

permissions:
contents: write

env:
CARGO_TERM_COLOR: always
RUSTC_WRAPPER: sccache
SCCACHE_GHA_ENABLED: true

jobs:
create-release:
runs-on: ubuntu-latest
steps:
- name: Create draft release (if missing)
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
set -euo pipefail
tag="${{ github.ref_name }}"
if gh release view "$tag" >/dev/null 2>&1; then
echo "Release $tag already exists"
else
gh release create "$tag" --draft --title "$tag" --verify-tag --notes-from-tag --fail-on-no-commits
fi

build:
name: Build (${{ matrix.target }})
needs: create-release
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
ext: tgz
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
ext: tgz
- os: macos-13
target: x86_64-apple-darwin
ext: tgz
- os: macos-14
target: aarch64-apple-darwin
ext: tgz
- os: windows-latest
target: x86_64-pc-windows-msvc
ext: zip
steps:
- uses: actions/checkout@v4
- name: Set version
shell: bash
run: echo "VERSION=${GITHUB_REF_NAME#sea-orm-cli@}" >> $GITHUB_ENV
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- uses: actions/cache@v5
with:
path: |
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-sea-orm-cli-release-${{ matrix.target }}-${{ hashFiles('**/Cargo.toml') }}
- uses: mozilla-actions/sccache-action@v0.0.9
- name: Build
run: cargo build --release --manifest-path sea-orm-cli/Cargo.toml --target ${{ matrix.target }} --bin sea-orm-cli
- name: Package (unix)
if: ${{ runner.os != 'Windows' }}
shell: bash
run: |
package="sea-orm-cli-${{ matrix.target }}-v${VERSION}"
mkdir -p "$package"
bin_cli="sea-orm-cli/target/${{ matrix.target }}/release/sea-orm-cli"
cp "$bin_cli" "$package/sea-orm-cli"
cp "$bin_cli" "$package/sea"
tar -czf "${package}.tgz" "$package"
- name: Package (windows)
if: ${{ runner.os == 'Windows' }}
shell: pwsh
run: |
$package = "sea-orm-cli-${{ matrix.target }}-v$env:VERSION"
New-Item -ItemType Directory -Path $package | Out-Null
$bin_cli = "sea-orm-cli/target/${{ matrix.target }}/release/sea-orm-cli.exe"
Copy-Item $bin_cli "$package/sea-orm-cli.exe"
Copy-Item $bin_cli "$package/sea.exe"
Compress-Archive -Path "$package" -DestinationPath "$package.zip"
- name: Upload release asset (unix)
if: ${{ runner.os != 'Windows' }}
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: gh release upload "${{ github.ref_name }}" "sea-orm-cli-${{ matrix.target }}-v${VERSION}.${{ matrix.ext }}" --clobber
- name: Upload release asset (windows)
if: ${{ runner.os == 'Windows' }}
shell: pwsh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: gh release upload "${{ github.ref_name }}" "sea-orm-cli-${{ matrix.target }}-v$env:VERSION.${{ matrix.ext }}" --clobber

publish:
name: Publish release
needs: build
runs-on: ubuntu-latest
steps:
- name: Publish release
shell: bash
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: gh release edit "${{ github.ref_name }}" --draft=false
15 changes: 15 additions & 0 deletions sea-orm-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ repository = "https://github.com/SeaQL/sea-orm"
rust-version = "1.85.0"
version = "2.0.0-rc.22"

[package.metadata.binstall]
bin-dir = "{ name }-{ target }-v{ version }/{ bin }{ binary-ext }"
pkg-fmt = "tgz"
pkg-url = "{ repo }/releases/download/sea-orm-cli@{ version }/{ name }-{ target }-v{ version }{ archive-suffix }"

[package.metadata.binstall.overrides.x86_64-pc-windows-msvc]
pkg-fmt = "zip"

[lib]
name = "sea_orm_cli"
path = "src/lib.rs"
Expand Down Expand Up @@ -126,6 +134,13 @@ runtime-tokio-rustls = [
"sea-schema?/runtime-tokio-rustls",
]

[profile.release]
codegen-units = 1
lto = true
opt-level = "s"
panic = "abort"
strip = true

# This allows us to develop using an overridden version of sea-query
[patch.crates-io]
# sea-query = { path = "../sea-query" }
Expand Down
Loading