name: Rust static build and publish on: push: tags: - '*' env: CARGO_TERM_COLOR: always BUILD_TARGET: x86_64-unknown-linux-musl BINARY_NAME: rexec jobs: build: name: Build static binary runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v3 - uses: dtolnay/rust-toolchain@stable - uses: mbrobbel/rustfmt-check@master with: token: ${{ secrets.GITHUB_TOKEN }} - name: Build-musl uses: gmiam/rust-musl-action@master with: args: cargo build --target $BUILD_TARGET --release - name: Get version run: echo "VERSION=$(grep -P '^version = \"\d+\.\d+\.\d+\"' Cargo.toml | awk -F '\"' '{print $2}')" >> $GITHUB_ENV - name: Show version run: echo ${{ env.VERSION }} - uses: actions/upload-artifact@v3.1.2 name: Upload artifact with: name: ${{ env.BINARY_NAME }}_${{ env.VERSION }}_${{ env.BUILD_TARGET }} path: target/${{ env.BUILD_TARGET }}/release/${{ env.BINARY_NAME }} build_arch: name: Arch Linux package runs-on: ubuntu-latest needs: ["build"] container: image: archlinux:base-devel options: --user 1001 permissions: contents: write steps: - uses: actions/checkout@v3 - name: Get version run: echo "VERSION=$(grep -P '^version = \"\d+\.\d+\.\d+\"' Cargo.toml | awk -F '\"' '{print $2}')" >> $GITHUB_ENV - uses: actions/download-artifact@master name: Download id: download_binary with: name: ${{ env.BINARY_NAME }}_${{ env.VERSION }}_${{ env.BUILD_TARGET }} path: ${{ env.BINARY_NAME }}_${{ env.VERSION }}_${{ env.BUILD_TARGET }} - name: Prepare build env run: | mkdir -p target/${{ env.BUILD_TARGET }}/release/ mv ${{ env.BINARY_NAME }}_${{ env.VERSION }}_${{ env.BUILD_TARGET }}/rexec target/${{ env.BUILD_TARGET }}/release/ sed -i -e "s/some_ver/${{ env.VERSION }}/" PKGBUILD - name: Build ZST package run: | makepkg -f - uses: actions/upload-artifact@v3.1.2 name: Upload artifact with: name: ${{ env.BINARY_NAME }}_${{ env.VERSION }}_${{ env.BUILD_TARGET }}.zst path: ${{ github.workspace }}/*zst release: name: Release binary needs: ["build" "build_arch"] runs-on: ubuntu-latest permissions: contents: write steps: - uses: actions/checkout@v3 - name: Get version run: echo "VERSION=$(grep -P '^version = \"\d+\.\d+\.\d+\"' Cargo.toml | awk -F '\"' '{print $2}')" >> $GITHUB_ENV - uses: actions/download-artifact@master name: Download binary id: download_binary with: name: ${{ env.BINARY_NAME }}_${{ env.VERSION }}_${{ env.BUILD_TARGET }} path: ${{ env.BINARY_NAME }}_${{ env.VERSION }}_${{ env.BUILD_TARGET }} - uses: actions/download-artifact@master id: download_pkg name: Download ZST package with: name: ${{ env.BINARY_NAME }}_${{ env.VERSION }}_${{ env.BUILD_TARGET }}.zst path: ${{ env.BINARY_NAME }}_${{ env.VERSION }}_${{ env.BUILD_TARGET }}.zst - uses: ncipollo/release-action@v1 name: Update release page with: artifacts: "${{ steps.download_binary.outputs.download-path }}/*,${{ steps.download_pkg.outputs.download-path }}/*" allowUpdates: true body: Static musl build for x86_64-linux and Arch Linux package