ZBR v1.7.0 #35
Workflow file for this run
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: Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*' | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| name: Build ${{ matrix.asset_name }} | |
| strategy: | |
| matrix: | |
| include: | |
| - os: ubuntu-latest | |
| target: x86_64-unknown-linux-gnu | |
| binary: zbr | |
| asset_name: zbr-linux-x64 | |
| cross: false | |
| - os: ubuntu-latest | |
| target: aarch64-linux-android | |
| binary: zbr | |
| asset_name: zbr-linux-arm64 | |
| cross: true | |
| - os: macos-latest | |
| target: x86_64-apple-darwin | |
| binary: zbr | |
| asset_name: zbr-darwin-x64 | |
| cross: false | |
| - os: macos-latest | |
| target: aarch64-apple-darwin | |
| binary: zbr | |
| asset_name: zbr-darwin-arm64 | |
| cross: false | |
| - os: windows-latest | |
| target: x86_64-pc-windows-msvc | |
| binary: zbr.exe | |
| asset_name: zbr-windows-x64.exe | |
| cross: false | |
| - os: windows-latest | |
| target: aarch64-pc-windows-msvc | |
| binary: zbr.exe | |
| asset_name: zbr-windows-arm64.exe | |
| cross: false | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Install Rust | |
| uses: dtolnay/rust-toolchain@stable | |
| with: | |
| targets: ${{ matrix.target }} | |
| - name: Cache cargo | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| ~/.cargo/registry | |
| ~/.cargo/git | |
| target | |
| key: ${{ matrix.os }}-${{ matrix.target }}-cargo-${{ hashFiles('**/Cargo.lock') }} | |
| - name: Install cross | |
| if: matrix.cross == true | |
| run: cargo install cross | |
| - name: Build | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.cross }}" == "true" ]; then | |
| cross build --release --target ${{ matrix.target }} | |
| else | |
| cargo build --release --target ${{ matrix.target }} | |
| fi | |
| - name: Rename binary | |
| shell: bash | |
| run: | | |
| if [ "${{ matrix.binary }}" != "${{ matrix.asset_name }}" ]; then | |
| mv target/${{ matrix.target }}/release/${{ matrix.binary }} target/${{ matrix.target }}/release/${{ matrix.asset_name }} | |
| fi | |
| - name: Create Release and Upload Asset | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: target/${{ matrix.target }}/release/${{ matrix.asset_name }} | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| publish: | |
| name: Publish to npm | |
| needs: build | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Extract version from tag | |
| id: tag_version | |
| run: echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT | |
| - name: Download and prepare binaries | |
| run: | | |
| for asset in zbr-linux-x64 zbr-linux-arm64 zbr-darwin-x64 zbr-darwin-arm64 zbr-windows-x64.exe zbr-windows-arm64.exe; do | |
| gh release download ${{ github.ref_name }} --pattern "$asset" | |
| done | |
| cp zbr-linux-x64 packages/zbr-linux-x64/ | |
| cp zbr-linux-arm64 packages/zbr-linux-arm64/ | |
| cp zbr-darwin-x64 packages/zbr-darwin-x64/ | |
| cp zbr-darwin-arm64 packages/zbr-darwin-arm64/ | |
| cp zbr-windows-x64.exe packages/zbr-windows-x64/ | |
| cp zbr-windows-arm64.exe packages/zbr-windows-arm64/ | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Update versions and publish platform packages | |
| run: | | |
| VERSION=${{ steps.tag_version.outputs.VERSION }} | |
| for pkg in packages/zbr-*; do | |
| cd $pkg | |
| npm pkg set version=$VERSION | |
| npm publish --access public | |
| cd ../.. | |
| done | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| - name: Update main package version and publish | |
| run: | | |
| VERSION=${{ steps.tag_version.outputs.VERSION }} | |
| npm pkg set version=$VERSION | |
| npm pkg set optionalDependencies.@zbrlang/zbr-linux-x64=$VERSION | |
| npm pkg set optionalDependencies.@zbrlang/zbr-linux-arm64=$VERSION | |
| npm pkg set optionalDependencies.@zbrlang/zbr-darwin-x64=$VERSION | |
| npm pkg set optionalDependencies.@zbrlang/zbr-darwin-arm64=$VERSION | |
| npm pkg set optionalDependencies.@zbrlang/zbr-windows-x64=$VERSION | |
| npm pkg set optionalDependencies.@zbrlang/zbr-windows-arm64=$VERSION | |
| npm publish --access public | |
| env: | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
| rebuild_hf_space: | |
| name: Rebuild HF Space | |
| needs: publish | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Trigger Rebuild | |
| run: | | |
| git clone https://Zubariel:${{ secrets.HF_TOKEN }}@huggingface.co/spaces/zbrlang/zbr-server hf-space | |
| cd hf-space | |
| echo ${{ github.ref_name }} > .build-version | |
| sed -i "s/ARG CACHEBUST=.*/ARG CACHEBUST=$(date +%s)/" Dockerfile | |
| git config user.email "ci@zbrlang.com" | |
| git config user.name "ZBR CI" | |
| git add .build-version Dockerfile | |
| git commit -m "rebuild for ${{ github.ref_name }}" | |
| git push |