From e169d7be68a1bd9706d3facb9bb7e87b380d542a Mon Sep 17 00:00:00 2001 From: Lucien Greathouse Date: Wed, 25 May 2022 22:26:22 -0400 Subject: [PATCH] New release workflow (#547) * Port release workflow from Aftman to test * Checkout submodules in plugin build step * ...and build with submodules for other builds too * Fix ci.yml; we use master branch still * CI with submodules too --- .github/workflows/ci.yml | 8 +- .github/workflows/release.yml | 199 ++++++++++++++++++++++++---------- 2 files changed, 149 insertions(+), 58 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 30110fa3..a589a7e7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -3,11 +3,11 @@ name: CI on: push: branches: - - main + - master pull_request: branches: - - main + - master jobs: build: @@ -20,6 +20,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + submodules: true - name: Install Rust uses: actions-rs/toolchain@v1 @@ -40,6 +42,8 @@ jobs: steps: - uses: actions/checkout@v3 + with: + submodules: true - name: Install Rust uses: actions-rs/toolchain@v1 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index bf43ed0f..05ec5bd4 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,65 +2,152 @@ name: Release on: push: - tags: ["*"] + tags: ["v*"] jobs: - windows: - runs-on: windows-latest - - steps: - - uses: actions/checkout@v1 - with: - submodules: true - - - name: Build release binary - run: cargo build --verbose --locked --release - - - name: Upload artifacts - uses: actions/upload-artifact@v1 - with: - name: rojo-win64 - path: target/release/rojo.exe - - macos: - runs-on: macos-latest - - steps: - - uses: actions/checkout@v1 - with: - submodules: true - - - name: Install Rust - run: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y - - - name: Build release binary - run: | - source $HOME/.cargo/env - cargo build --verbose --locked --release - env: - OPENSSL_STATIC: 1 - - - name: Upload artifacts - uses: actions/upload-artifact@v1 - with: - name: rojo-macos - path: target/release/rojo - - linux: + create-release: + name: Create Release runs-on: ubuntu-latest - + outputs: + upload_url: ${{ steps.create_release.outputs.upload_url }} steps: - - uses: actions/checkout@v1 - with: - submodules: true + - name: Create Release + id: create_release + uses: actions/create-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + tag_name: ${{ github.ref }} + release_name: ${{ github.ref }} + draft: true + prerelease: false - - name: Build - run: cargo build --locked --verbose --release - env: - OPENSSL_STATIC: 1 + build-plugin: + needs: ["create-release"] + name: Build Roblox Studio Plugin + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + submodules: true - - name: Upload artifacts - uses: actions/upload-artifact@v1 - with: - name: rojo-linux - path: target/release/rojo \ No newline at end of file + - name: Setup Foreman + uses: Roblox/setup-foreman@v1 + with: + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Build Plugin + run: rojo build plugin --output Rojo.rbxm + + - name: Upload Plugin to Release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: Rojo.rbxm + asset_name: Rojo.rbxm + asset_content_type: application/octet-stream + + - name: Upload Plugin to Artifacts + uses: actions/upload-artifact@v3 + with: + name: Rojo.rbxm + path: Rojo.rbxm + + build: + needs: ["create-release"] + strategy: + fail-fast: false + matrix: + # https://doc.rust-lang.org/rustc/platform-support.html + # + # FIXME: After the Rojo VS Code extension updates, add architecture + # names to each of these releases. We'll rename win64 to windows and add + # -x86_64 to each release. + include: + - host: linux + os: ubuntu-latest + target: x86_64-unknown-linux-gnu + label: linux + + - host: windows + os: windows-latest + target: x86_64-pc-windows-msvc + label: win64 + + - host: macos + os: macos-latest + target: x86_64-apple-darwin + label: macos + + - host: macos + os: macos-latest + target: aarch64-apple-darwin + label: macos-aarch64 + + name: Build (${{ matrix.target }}) + runs-on: ${{ matrix.os }} + env: + BIN: rojo + steps: + - uses: actions/checkout@v3 + with: + submodules: true + + - name: Get Version from Tag + shell: bash + # https://github.community/t/how-to-get-just-the-tag-name/16241/7#M1027 + run: | + echo "PROJECT_VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_ENV + echo "Version is: ${{ env.PROJECT_VERSION }}" + + - name: Install Rust + uses: actions-rs/toolchain@v1 + with: + toolchain: stable + target: ${{ matrix.target }} + override: true + profile: minimal + + - name: Build Release + run: cargo build --release --locked --verbose + env: + # Build into a known directory so we can find our build artifact more + # easily. + CARGO_TARGET_DIR: output + + # On platforms that use OpenSSL, ensure it is statically linked to + # make binaries more portable. + OPENSSL_STATIC: 1 + + - name: Create Release Archive + shell: bash + run: | + mkdir staging + + if [ "${{ matrix.host }}" = "windows" ]; then + cp "output/release/$BIN.exe" staging/ + cd staging + 7z a ../release.zip * + else + cp "output/release/$BIN" staging/ + cd staging + zip ../release.zip * + fi + + - name: Upload Archive to Release + uses: actions/upload-release-asset@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + upload_url: ${{ needs.create-release.outputs.upload_url }} + asset_path: release.zip + asset_name: ${{ env.BIN }}-${{ env.PROJECT_VERSION }}-${{ matrix.label }}.zip + asset_content_type: application/octet-stream + + - name: Upload Archive to Artifacts + uses: actions/upload-artifact@v3 + with: + name: ${{ env.BIN }}-${{ env.PROJECT_VERSION }}-${{ matrix.label }}.zip + path: release.zip \ No newline at end of file