diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index ab32750..c293dba 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -1,77 +1,71 @@ -name: Deploy +name: Release on: push: - tags: - - "[0-9]+.[0-9]+.[0-9]+" - -permissions: - contents: write + branches: + - master jobs: - build-and-upload: - name: Build and upload - runs-on: ${{ matrix.os }} + build: + runs-on: ubuntu-latest strategy: matrix: - # You can add more, for any target you'd like! - include: - - build: linux - os: ubuntu-latest - target: x86_64-unknown-linux-musl - - - build: macos - os: macos-latest - target: x86_64-apple-darwin + target: [x86_64-pc-windows-gnu, x86_64-unknown-linux-gnu] steps: - - name: Checkout - uses: actions/checkout@v3 + - name: Checkout code + uses: actions/checkout@v2 - - name: Get the release version from the tag - shell: bash - run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV - - - name: Install Rust - # Or @nightly if you want - uses: dtolnay/rust-toolchain@stable - # Arguments to pass in + - name: Set up Rust + uses: actions-rs/toolchain@v1 with: - # Make Rust compile to our target (defined in the matrix) - targets: ${{ matrix.target }} + toolchain: stable - name: Build - uses: actions-rs/cargo@v1 + run: cargo build --release --target ${{ matrix.target }} + + - name: Upload artifact + uses: actions/upload-artifact@v2 with: - use-cross: true - command: build - args: --verbose --release --target ${{ matrix.target }} + name: ${{ matrix.target }}-binary + path: target/${{ matrix.target }}/release/ - - name: Build archive - shell: bash - run: | - # Replace with the name of your binary - binary_name="BeetleWire" + release: + needs: build + runs-on: ubuntu-latest - dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}" - mkdir "$dirname" - if [ "${{ matrix.os }}" = "windows-latest" ]; then - mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname" - else - mv "target/${{ matrix.target }}/release/$binary_name" "$dirname" - fi + steps: + - name: Checkout code + uses: actions/checkout@v2 - if [ "${{ matrix.os }}" = "windows-latest" ]; then - 7z a "$dirname.zip" "$dirname" - echo "ASSET=$dirname.zip" >> $GITHUB_ENV - else - tar -czf "$dirname.tar.gz" "$dirname" - echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV - fi - - - name: Release - uses: softprops/action-gh-release@v1 + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - files: | - ${{ env.ASSET }} + tag_name: v${{ github.run_number }} + release_name: Release ${{ github.run_number }} + draft: false + prerelease: false + + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: target/x86_64-pc-windows-gnu/release/ + asset_name: windows-binary.zip + asset_content_type: application/zip + + - name: Upload Release Asset + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ steps.create_release.outputs.upload_url }} + asset_path: target/x86_64-unknown-linux-gnu/release/ + asset_name: linux-binary.tar.gz + asset_content_type: application/gzip