@@ -0,0 +1,97 @@
1+name: Build and Release
2+
3+on:
4+ push:
5+ branches: [main, master]
6+ tags: ['v*']
7+ workflow_dispatch:
8+
9+jobs:
10+ build:
11+ name: Build ${{ matrix.target }}
12+ runs-on: ${{ matrix.os }}
13+ strategy:
14+ matrix:
15+ include:
16+ - os: ubuntu-latest
17+ target: x86_64-unknown-linux-gnu
18+ name: htmlang-linux-x86_64
19+ - os: macos-latest
20+ target: x86_64-apple-darwin
21+ name: htmlang-macos-x86_64
22+ - os: macos-latest
23+ target: aarch64-apple-darwin
24+ name: htmlang-macos-aarch64
25+ - os: windows-latest
26+ target: x86_64-pc-windows-msvc
27+ name: htmlang-windows-x86_64.exe
28+ steps:
29+ - uses: actions/checkout@v4
30+
31+ - uses: dtolnay/rust-toolchain@stable
32+ with:
33+ targets: ${{ matrix.target }}
34+
35+ - name: Build binary
36+ run: cargo build --release --target ${{ matrix.target }}
37+
38+ - name: Strip binary (Unix)
39+ if: runner.os != 'Windows'
40+ run: |
41+ if [ -f target/${{ matrix.target }}/release/htmlang ]; then
42+ strip target/${{ matrix.target }}/release/htmlang
43+ fi
44+
45+ - name: Upload artifact
46+ uses: actions/upload-artifact@v4
47+ with:
48+ name: ${{ matrix.name }}
49+ path: target/${{ matrix.target }}/release/htmlang${{ runner.os == 'Windows' && '.exe' || '' }}
50+
51+ release:
52+ name: Create Release
53+ needs: build
54+ runs-on: ubuntu-latest
55+ permissions:
56+ contents: write
57+ steps:
58+ - uses: actions/checkout@v4
59+
60+ - name: Download all artifacts
61+ uses: actions/download-artifact@v4
62+ with:
63+ path: artifacts
64+
65+ - name: Calculate version
66+ id: version
67+ run: |
68+ VERSION=$(date -u +'%Y.%m.%d.%H%M%S')
69+ echo "version=$VERSION" >> $GITHUB_OUTPUT
70+ echo "Version: $VERSION"
71+
72+ - name: Prepare release assets
73+ run: |
74+ mkdir -p release
75+ for dir in artifacts/*/; do
76+ filename=$(basename "$dir")
77+ binary=$(find "$dir" -type f -executable | head -1)
78+ if [ -z "$binary" ] && [ -f "$dir/htmlang.exe" ]; then
79+ binary="$dir/htmlang.exe"
80+ fi
81+ if [ -n "$binary" ]; then
82+ cp "$binary" "release/$filename"
83+ chmod +x "release/$filename"
84+ fi
85+ done
86+ ls -la release/
87+
88+ - name: Create Release
89+ uses: softprops/action-gh-release@v1
90+ with:
91+ tag_name: v${{ steps.version.outputs.version }}
92+ name: Release ${{ steps.version.outputs.version }}
93+ files: release/*
94+ draft: false
95+ prerelease: false
96+ env:
97+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}