Skip to content

docs: change socialify banner to show Rust as primary lang #13

docs: change socialify banner to show Rust as primary lang

docs: change socialify banner to show Rust as primary lang #13

Workflow file for this run

name: Build & Release
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: write
jobs:
# โ”€โ”€ ๅˆคๆ–ญๆ˜ฏๅฆ้œ€่ฆๆž„ๅปบ / ๅ‘ๅธƒ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
check:
name: Check commit message
runs-on: ubuntu-latest
outputs:
should_build: ${{ steps.flags.outputs.should_build }}
should_release: ${{ steps.flags.outputs.should_release }}
should_publish: ${{ steps.flags.outputs.should_publish }}
version: ${{ steps.flags.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Parse commit message
id: flags
run: |
MSG="${{ github.event.head_commit.message }}"
# ไปŽ Cargo.toml ๆๅ–็‰ˆๆœฌๅท
VERSION="v$(grep '^version' rust/Cargo.toml | head -1 | sed 's/.*"\(.*\)".*/\1/')"
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
echo "๐Ÿ“ฆ Version: $VERSION"
# PR ๅง‹็ปˆๆž„ๅปบ
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "should_build=true" >> "$GITHUB_OUTPUT"
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "should_publish=false" >> "$GITHUB_OUTPUT"
exit 0
fi
# "build publish" = ๅฎŒๆ•ดๅ‘ๅธƒๆต็จ‹
if echo "$MSG" | grep -qi "build publish"; then
echo "should_build=true" >> "$GITHUB_OUTPUT"
echo "should_release=true" >> "$GITHUB_OUTPUT"
echo "should_publish=true" >> "$GITHUB_OUTPUT"
# "build release" = ๆž„ๅปบ + GitHub Release
elif echo "$MSG" | grep -qi "build release"; then
echo "should_build=true" >> "$GITHUB_OUTPUT"
echo "should_release=true" >> "$GITHUB_OUTPUT"
echo "should_publish=false" >> "$GITHUB_OUTPUT"
# "build action" = ไป…ๆž„ๅปบ
elif echo "$MSG" | grep -qi "build action"; then
echo "should_build=true" >> "$GITHUB_OUTPUT"
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "should_publish=false" >> "$GITHUB_OUTPUT"
else
echo "should_build=false" >> "$GITHUB_OUTPUT"
echo "should_release=false" >> "$GITHUB_OUTPUT"
echo "should_publish=false" >> "$GITHUB_OUTPUT"
fi
# โ”€โ”€ ๅคšๅนณๅฐๆž„ๅปบ โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
build:
name: Build ${{ matrix.name }}
needs: check
if: needs.check.outputs.should_build == 'true'
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
# โ”€โ”€ Windows x64 (MSVC, native) โ”€โ”€
- target: x86_64-pc-windows-msvc
os: windows-latest
name: windows-x86_64
binary: winload.exe
asset: winload-windows-x86_64.exe
# โ”€โ”€ Linux x64 (musl ้™ๆ€้“พๆŽฅ, ๅ…ผๅฎนๆ‰€ๆœ‰ Linux) โ”€โ”€
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
name: linux-x86_64
binary: winload
asset: winload-linux-x86_64
cross_packages: musl-tools
# โ”€โ”€ Windows ARM64 (cross-compile on x64 runner) โ”€โ”€
- target: aarch64-pc-windows-msvc
os: windows-latest
name: windows-aarch64
binary: winload.exe
asset: winload-windows-aarch64.exe
# โ”€โ”€ Linux ARM64 (ubuntu-22.04 ้™ไฝŽ GLIBC ่ฆๆฑ‚) โ”€โ”€
- target: aarch64-unknown-linux-gnu
os: ubuntu-22.04
name: linux-aarch64
binary: winload
asset: winload-linux-aarch64
cross_linker: aarch64-linux-gnu-gcc
cross_packages: gcc-aarch64-linux-gnu
# โ”€โ”€ macOS x64 (build on Apple Silicon runner) โ”€โ”€
- target: x86_64-apple-darwin
os: macos-latest
name: macos-x86_64
binary: winload
asset: winload-macos-x86_64
# โ”€โ”€ macOS ARM64 (Apple Silicon runner) โ”€โ”€
- target: aarch64-apple-darwin
os: macos-latest
name: macos-aarch64
binary: winload
asset: winload-macos-aarch64
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
workspaces: rust -> target
cache-on-failure: true
- name: Install platform toolchain
if: matrix.cross_packages
run: |
sudo apt-get update
sudo apt-get install -y ${{ matrix.cross_packages }}
- name: Build release binary
working-directory: rust
env:
# ไบคๅ‰็ผ–่ฏ‘ๆ—ถๆŒ‡ๅฎš้“พๆŽฅๅ™จ (ไป… aarch64-linux-gnu ้œ€่ฆ)
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: ${{ matrix.cross_linker || '' }}
run: |
cargo build --release --target ${{ matrix.target }}
# ้ชŒ่ฏ Linux musl ไบง็‰ฉๆ˜ฏๅฆ็œŸ็š„ๆ˜ฏ้™ๆ€้“พๆŽฅ
if [[ "${{ matrix.target }}" == *musl* ]]; then
echo "๐Ÿ” Verifying static linking..."
file target/${{ matrix.target }}/release/${{ matrix.binary }}
ldd target/${{ matrix.target }}/release/${{ matrix.binary }} 2>&1 || echo "โœ… Statically linked (no dynamic dependencies)"
fi
- name: Prepare artifact
shell: bash
run: |
VERSION="${{ needs.check.outputs.version }}"
ASSET_BASE="${{ matrix.asset }}"
# ๅœจๆ‰ฉๅฑ•ๅๅ‰ๆ’ๅ…ฅ็‰ˆๆœฌๅท
# winload-linux-x86_64 -> winload-linux-x86_64-v0.1.0
# winload-windows-x86_64.exe -> winload-windows-x86_64-v0.1.0.exe
if [[ "$ASSET_BASE" == *.* ]]; then
# ๆœ‰ๆ‰ฉๅฑ•ๅ
BASE_NAME="${ASSET_BASE%.*}"
EXTENSION="${ASSET_BASE##*.}"
ASSET_WITH_VERSION="${BASE_NAME}-${VERSION}.${EXTENSION}"
else
# ๆ— ๆ‰ฉๅฑ•ๅ
ASSET_WITH_VERSION="${ASSET_BASE}-${VERSION}"
fi
echo "๐Ÿ“ฆ Output: $ASSET_WITH_VERSION"
cp "rust/target/${{ matrix.target }}/release/${{ matrix.binary }}" "$ASSET_WITH_VERSION"
echo "asset_name=$ASSET_WITH_VERSION" >> "$GITHUB_ENV"
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: ${{ env.asset_name }}
path: ${{ env.asset_name }}
# โ”€โ”€ ๅ‘ๅธƒๅˆฐ GitHub Releases โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
release:
name: Publish Release
needs: [check, build]
if: needs.check.outputs.should_release == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
merge-multiple: true
- name: List downloaded files
run: |
echo "Downloaded artifacts:"
ls -lh
- name: Delete existing release & tag (force fresh release)
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION="${{ needs.check.outputs.version }}"
echo "๐Ÿ—‘๏ธ Cleaning up existing release/tag: $VERSION"
gh release delete "$VERSION" --yes --cleanup-tag 2>/dev/null || echo "No existing release to delete"
# ็ญ‰ๅพ… GitHub API ๅŒๆญฅ
sleep 3
- name: Generate release notes from commits
run: |
VERSION="${{ needs.check.outputs.version }}"
# ๆŸฅๆ‰พไธŠไธ€ไธช release tag๏ผˆๆŽ’้™คๅฝ“ๅ‰็‰ˆๆœฌ๏ผ‰
PREV_TAG=$(git tag --sort=-v:refname | grep -v "^${VERSION}$" | head -1)
{
echo "## ๐Ÿ“ฆ winload ${VERSION}"
echo ""
echo "### What's Changed"
echo ""
if [ -n "$PREV_TAG" ]; then
echo "Changes since **${PREV_TAG}**:"
echo ""
git log "${PREV_TAG}..HEAD" --pretty=format:"- %s (\`%h\`) โ€” @%an" --reverse
else
echo "All changes since repository creation:"
echo ""
git log --pretty=format:"- %s (\`%h\`) โ€” @%an" --reverse
fi
echo ""
echo ""
echo "---"
echo ""
echo "### ๐Ÿ“Š Build Info"
echo "- **Build date**: $(date -u '+%Y-%m-%d %H:%M UTC')"
echo "- **Commit**: [\`${GITHUB_SHA::7}\`](https://github.com/${{ github.repository }}/commit/${GITHUB_SHA})"
echo ""
if [ -n "$PREV_TAG" ]; then
echo "**Full Changelog**: https://github.com/${{ github.repository }}/compare/${PREV_TAG}...${VERSION}"
else
echo "**Full Changelog**: https://github.com/${{ github.repository }}/commits/${VERSION}"
fi
} > release_notes.md
echo "๐Ÿ“ Generated release notes:"
cat release_notes.md
- name: Create GitHub Release
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION="${{ needs.check.outputs.version }}"
gh release create "$VERSION" \
--title "winload ${VERSION}" \
--notes-file release_notes.md \
--latest \
winload-*-${VERSION}*