diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..26b24af --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,104 @@ +name: Release + +on: + workflow_dispatch: + inputs: + release_name: + description: 'Release Name' + required: false + default: '' + +jobs: + build: + name: Build on ${{ matrix.os }} for ${{ matrix.arch }} + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + include: + - os: ubuntu-latest + arch: amd64 + target: x86_64-unknown-linux-gnu + # - os: ubuntu-latest + # arch: arm64 + # target: aarch64-unknown-linux-gnu + - os: macos-latest + arch: amd64 + target: x86_64-apple-darwin + - os: macos-latest + arch: arm64 + target: aarch64-apple-darwin + - os: windows-latest + arch: amd64 + target: x86_64-pc-windows-msvc + + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Install Common Dependencies (Ubuntu) + if: startsWith(matrix.os, 'ubuntu') + run: | + sudo apt-get update + sudo apt-get install -y pkg-config libssl-dev + + - name: Install Cross-Compilation Tools for ARM64 + if: matrix.target == 'aarch64-unknown-linux-gnu' + run: | + sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu + + - name: Configure PKG_CONFIG_PATH for ARM64 + if: matrix.target == 'aarch64-unknown-linux-gnu' + run: | + echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV + echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV + + - name: Set up Environment for Cross-Compilation (ARM64) + if: matrix.target == 'aarch64-unknown-linux-gnu' + run: | + echo "PKG_CONFIG_ALLOW_CROSS=1" >> $GITHUB_ENV + echo "PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig" >> $GITHUB_ENV + echo "OPENSSL_DIR=/usr/lib/aarch64-linux-gnu" >> $GITHUB_ENV + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + profile: minimal + override: true + target: ${{ matrix.target }} + + - name: Build Binary + run: | + cd rust + cargo build --release --manifest-path=crates/mesc_cli/Cargo.toml --target ${{ matrix.target }} + + - name: Upload Artifact + uses: actions/upload-artifact@v2 + with: + name: binary-${{ matrix.target }} + path: rust/target/${{ matrix.target }}/release/mesc + + publish_release: + needs: build + runs-on: ubuntu-latest + steps: + - name: Checkout Repository + uses: actions/checkout@v2 + + - name: Download All Artifacts + uses: actions/download-artifact@v2 + with: + path: artifacts + + - name: Create Release + id: create_release + uses: softprops/action-gh-release@v1 + with: + files: artifacts/** + name: ${{ github.event.inputs.release_name || github.ref_name }} + tag_name: ${{ github.ref_name }} + draft: false + prerelease: false + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}