docs: change socialify banner to show Rust as primary lang #13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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}* |