From 6aef1ebd700d66abe5e44eadd9dc7b6192a7793f Mon Sep 17 00:00:00 2001 From: Wu Wayne Date: Thu, 29 Feb 2024 15:59:34 +0900 Subject: [PATCH 01/21] Add release CI pipeline --- .github/workflows/release.yml | 217 ++++++++++++++++++++++++++++++++++ 1 file changed, 217 insertions(+) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000000..723db0dfed2 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,217 @@ +name: Rust + +on: + push: + branches: [main] + pull_request: + +env: + RUST_BACKTRACE: 1 + SHELL: /bin/bash + CARGO_INCREMENTAL: 0 + MOZJS_CREATE_ARCHIVE: 1 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository_owner }}/mozjs + +jobs: + mac-arm: + runs-on: macos-14 + needs: create-release + strategy: + fail-fast: false + matrix: + features: ["--features streams"] + env: + RUSTC_WRAPPER: sccache + CCACHE: sccache + SCCACHE_GHA_ENABLED: "true" + RELEASE_ID: ${{ needs.create-release.outputs.release-id }} + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + # Unlink and re-link to prevent errors when github mac runner images + # https://github.com/actions/setup-python/issues/577 + brew list -1 | grep python | while read formula; do brew unlink $formula; brew link --overwrite $formula; done + brew install llvm yasm + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Build + run: | + cargo build --verbose ${{ matrix.features }} + cargo test --tests --examples --verbose ${{ matrix.features }} + - name: Upload release asset + run: | + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -H "Content-Type: application/octet-stream" \ + "https://uploads.github.com/repos/${REPO}/releases/${RELEASE_ID}/assets?name=libmozjs-aarch64-apple-darwin.tar.gz" \ + --data-binary "@target/libmozjs-aarch64-apple-darwin.tar.gz" + + mac-x86_64: + runs-on: macos-13 + needs: create-release + strategy: + fail-fast: false + matrix: + features: ["--features streams"] + env: + RUSTC_WRAPPER: sccache + CCACHE: sccache + SCCACHE_GHA_ENABLED: "true" + RELEASE_ID: ${{ needs.create-release.outputs.release-id }} + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + # Unlink and re-link to prevent errors when github mac runner images + # https://github.com/actions/setup-python/issues/577 + brew list -1 | grep python | while read formula; do brew unlink $formula; brew link --overwrite $formula; done + brew install llvm yasm + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Build + run: | + cargo build --verbose ${{ matrix.features }} + cargo test --tests --examples --verbose ${{ matrix.features }} + - name: Upload release asset + run: | + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -H "Content-Type: application/octet-stream" \ + "https://uploads.github.com/repos/${REPO}/releases/${RELEASE_ID}/assets?name=libmozjs-x86_64-apple-darwin.tar.gz" \ + --data-binary "@target/libmozjs-x86_64-apple-darwin.tar.gz" + + linux: + env: + RUSTC_WRAPPER: "sccache" + CCACHE: sccache + SCCACHE_GHA_ENABLED: "true" + runs-on: ubuntu-latest + needs: create-release + strategy: + fail-fast: false + matrix: + features: ["--features streams"] + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Install deps + run: | + sudo apt install llvm -y + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Build + run: | + cargo build --verbose ${{ matrix.features }} + cargo test --tests --examples --verbose ${{ matrix.features }} + - name: Upload release asset + env: + RELEASE_ID: ${{ needs.create-release.outputs.release-id }} + run: | + curl -L \ + -X POST \ + -H "Accept: application/vnd.github+json" \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + -H "Content-Type: application/octet-stream" \ + "https://uploads.github.com/repos/${REPO}/releases/${RELEASE_ID}/assets?name=libmozjs-x86_64-unknown-linux-gnu.tar.gz" \ + --data-binary "@target/libmozjs-x86_64-unknown-linux-gnu.tar.gz" + + windows: + runs-on: windows-latest + needs: create-release + strategy: + fail-fast: false + matrix: + features: ["--features streams"] + env: + LINKER: "lld-link.exe" + CC: "clang-cl" + CXX: "clang-cl" + MOZTOOLS_PATH: "${{ github.workspace }}\\target\\dependencies\\moztools-4.0" + CCACHE: sccache + SCCACHE_GHA_ENABLED: "true" + RELEASE_ID: ${{ needs.create-release.outputs.release-id }} + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + - name: Install deps + run: | + curl -SL "https://github.com/servo/servo-build-deps/releases/download/msvc-deps/moztools-4.0.zip" --create-dirs -o target/dependencies/moztools.zip + cd target/dependencies && unzip -qo moztools.zip -d . + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Build Windows + shell: cmd + run: | + cargo build --verbose ${{ matrix.features }} + cargo test --tests --examples --verbose ${{ matrix.features }} + - name: Upload release asset + uses: actions/upload-release-asset@v1 + with: + upload_url: https://uploads.github.com/repos/${{ github.repository_owner }}/mozjs/releases/${{ needs.create-release.outputs.release-id }}/assets{?name,label} + asset_path: ./target/libmozjs-x86_64-pc-windows-msvc.tar.gz + asset_name: libmozjs-x86_64-pc-windows-msvc.tar.gz + asset_content_type: application/tar+gzip + + create-release: + runs-on: ubuntu-latest + steps: + - name: Create release + id: create-release + run: | + NIGHTLY_TAG=$(date "+%F") + RELEASE_URL=$(gh release create "${NIGHTLY_TAG}" \ + --draft \ + --title "${NIGHTLY_TAG}" \ + --notes 'Version release based on servo/mozjs@${{ github.sha }}' \ + --repo ${REPO}) + TEMP_TAG=$(basename "$RELEASE_URL") + RELEASE_ID=$( \ + gh api -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "/repos/${REPO}/releases/tags/${TEMP_TAG}" \ + | jq '.id' \ + ) + echo "RELEASE_ID=${RELEASE_ID}" >> ${GITHUB_OUTPUT} + outputs: + release-id: ${{ steps.create-release.outputs.RELEASE_ID }} + + publish-release: + name: Result + runs-on: ubuntu-latest + needs: + ["create-release", "mac-arm", "mac-x86_64", "linux", "windows"] + if: ${{ always() }} + env: + RELEASE_ID: ${{ needs.create-release.outputs.release-id }} + steps: + - name: Publish as latest (success) + if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} + run: | + gh api \ + --method PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${REPO}/releases/${RELEASE_ID} \ + -F draft=false + - name: Publish as latest (failure) + if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} + run: | + gh api \ + --method PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${REPO}/releases/${RELEASE_ID} \ + -F prerelease=true -F draft=false + + From ad84256598d2fa36be93d740d8a364d064b1ba45 Mon Sep 17 00:00:00 2001 From: Wu Wayne Date: Thu, 29 Feb 2024 16:05:44 +0900 Subject: [PATCH 02/21] Rename CI pipeline --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 723db0dfed2..73a9a392ad1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Rust +name: Prebuilt mozjs release on: push: From c5bf7c2a0c78e91da251893fccbdab159edfaa7c Mon Sep 17 00:00:00 2001 From: Wu Wayne Date: Thu, 29 Feb 2024 18:10:03 +0900 Subject: [PATCH 03/21] Update CI trigger condition --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 73a9a392ad1..cba5fbc50b5 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,7 +3,6 @@ name: Prebuilt mozjs release on: push: branches: [main] - pull_request: env: RUST_BACKTRACE: 1 From d3e69acfb3e8e7baeb5dd2ea7ffdf0f6c7e212aa Mon Sep 17 00:00:00 2001 From: Wu Wayne Date: Thu, 29 Feb 2024 19:38:05 +0900 Subject: [PATCH 04/21] Merge CI into one file --- .github/workflows/release.yml | 216 ---------------------------------- .github/workflows/rust.yml | 86 +++++++++++++- 2 files changed, 81 insertions(+), 221 deletions(-) delete mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index cba5fbc50b5..00000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,216 +0,0 @@ -name: Prebuilt mozjs release - -on: - push: - branches: [main] - -env: - RUST_BACKTRACE: 1 - SHELL: /bin/bash - CARGO_INCREMENTAL: 0 - MOZJS_CREATE_ARCHIVE: 1 - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPO: ${{ github.repository_owner }}/mozjs - -jobs: - mac-arm: - runs-on: macos-14 - needs: create-release - strategy: - fail-fast: false - matrix: - features: ["--features streams"] - env: - RUSTC_WRAPPER: sccache - CCACHE: sccache - SCCACHE_GHA_ENABLED: "true" - RELEASE_ID: ${{ needs.create-release.outputs.release-id }} - steps: - - uses: actions/checkout@v4 - - name: Install deps - run: | - # Unlink and re-link to prevent errors when github mac runner images - # https://github.com/actions/setup-python/issues/577 - brew list -1 | grep python | while read formula; do brew unlink $formula; brew link --overwrite $formula; done - brew install llvm yasm - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 - - name: Build - run: | - cargo build --verbose ${{ matrix.features }} - cargo test --tests --examples --verbose ${{ matrix.features }} - - name: Upload release asset - run: | - curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${GITHUB_TOKEN}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -H "Content-Type: application/octet-stream" \ - "https://uploads.github.com/repos/${REPO}/releases/${RELEASE_ID}/assets?name=libmozjs-aarch64-apple-darwin.tar.gz" \ - --data-binary "@target/libmozjs-aarch64-apple-darwin.tar.gz" - - mac-x86_64: - runs-on: macos-13 - needs: create-release - strategy: - fail-fast: false - matrix: - features: ["--features streams"] - env: - RUSTC_WRAPPER: sccache - CCACHE: sccache - SCCACHE_GHA_ENABLED: "true" - RELEASE_ID: ${{ needs.create-release.outputs.release-id }} - steps: - - uses: actions/checkout@v4 - - name: Install deps - run: | - # Unlink and re-link to prevent errors when github mac runner images - # https://github.com/actions/setup-python/issues/577 - brew list -1 | grep python | while read formula; do brew unlink $formula; brew link --overwrite $formula; done - brew install llvm yasm - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 - - name: Build - run: | - cargo build --verbose ${{ matrix.features }} - cargo test --tests --examples --verbose ${{ matrix.features }} - - name: Upload release asset - run: | - curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${GITHUB_TOKEN}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -H "Content-Type: application/octet-stream" \ - "https://uploads.github.com/repos/${REPO}/releases/${RELEASE_ID}/assets?name=libmozjs-x86_64-apple-darwin.tar.gz" \ - --data-binary "@target/libmozjs-x86_64-apple-darwin.tar.gz" - - linux: - env: - RUSTC_WRAPPER: "sccache" - CCACHE: sccache - SCCACHE_GHA_ENABLED: "true" - runs-on: ubuntu-latest - needs: create-release - strategy: - fail-fast: false - matrix: - features: ["--features streams"] - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - name: Install deps - run: | - sudo apt install llvm -y - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 - - name: Build - run: | - cargo build --verbose ${{ matrix.features }} - cargo test --tests --examples --verbose ${{ matrix.features }} - - name: Upload release asset - env: - RELEASE_ID: ${{ needs.create-release.outputs.release-id }} - run: | - curl -L \ - -X POST \ - -H "Accept: application/vnd.github+json" \ - -H "Authorization: Bearer ${GITHUB_TOKEN}" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - -H "Content-Type: application/octet-stream" \ - "https://uploads.github.com/repos/${REPO}/releases/${RELEASE_ID}/assets?name=libmozjs-x86_64-unknown-linux-gnu.tar.gz" \ - --data-binary "@target/libmozjs-x86_64-unknown-linux-gnu.tar.gz" - - windows: - runs-on: windows-latest - needs: create-release - strategy: - fail-fast: false - matrix: - features: ["--features streams"] - env: - LINKER: "lld-link.exe" - CC: "clang-cl" - CXX: "clang-cl" - MOZTOOLS_PATH: "${{ github.workspace }}\\target\\dependencies\\moztools-4.0" - CCACHE: sccache - SCCACHE_GHA_ENABLED: "true" - RELEASE_ID: ${{ needs.create-release.outputs.release-id }} - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.target }} - - name: Install deps - run: | - curl -SL "https://github.com/servo/servo-build-deps/releases/download/msvc-deps/moztools-4.0.zip" --create-dirs -o target/dependencies/moztools.zip - cd target/dependencies && unzip -qo moztools.zip -d . - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 - - name: Build Windows - shell: cmd - run: | - cargo build --verbose ${{ matrix.features }} - cargo test --tests --examples --verbose ${{ matrix.features }} - - name: Upload release asset - uses: actions/upload-release-asset@v1 - with: - upload_url: https://uploads.github.com/repos/${{ github.repository_owner }}/mozjs/releases/${{ needs.create-release.outputs.release-id }}/assets{?name,label} - asset_path: ./target/libmozjs-x86_64-pc-windows-msvc.tar.gz - asset_name: libmozjs-x86_64-pc-windows-msvc.tar.gz - asset_content_type: application/tar+gzip - - create-release: - runs-on: ubuntu-latest - steps: - - name: Create release - id: create-release - run: | - NIGHTLY_TAG=$(date "+%F") - RELEASE_URL=$(gh release create "${NIGHTLY_TAG}" \ - --draft \ - --title "${NIGHTLY_TAG}" \ - --notes 'Version release based on servo/mozjs@${{ github.sha }}' \ - --repo ${REPO}) - TEMP_TAG=$(basename "$RELEASE_URL") - RELEASE_ID=$( \ - gh api -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "/repos/${REPO}/releases/tags/${TEMP_TAG}" \ - | jq '.id' \ - ) - echo "RELEASE_ID=${RELEASE_ID}" >> ${GITHUB_OUTPUT} - outputs: - release-id: ${{ steps.create-release.outputs.RELEASE_ID }} - - publish-release: - name: Result - runs-on: ubuntu-latest - needs: - ["create-release", "mac-arm", "mac-x86_64", "linux", "windows"] - if: ${{ always() }} - env: - RELEASE_ID: ${{ needs.create-release.outputs.release-id }} - steps: - - name: Publish as latest (success) - if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} - run: | - gh api \ - --method PATCH \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - /repos/${REPO}/releases/${RELEASE_ID} \ - -F draft=false - - name: Publish as latest (failure) - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} - run: | - gh api \ - --method PATCH \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - /repos/${REPO}/releases/${RELEASE_ID} \ - -F prerelease=true -F draft=false - - diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 8ee0a1c5f3c..7e6f3c7c46a 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -15,14 +15,20 @@ env: RUST_BACKTRACE: 1 SHELL: /bin/bash CARGO_INCREMENTAL: 0 + MOZJS_CREATE_ARCHIVE: 1 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository_owner }}/mozjs jobs: mac: - runs-on: macos-13 strategy: fail-fast: false matrix: - features: ["--features debugmozjs", ""] + features: ["--features debugmozjs", "--features streams"] + platform: + - { target: aarch64-apple-darwin, os: macos-14 } + - { target: x86_64-apple-darwin, os: macos-13 } + runs-on: ${{ matrix.platform.os }} env: RUSTC_WRAPPER: sccache CCACHE: sccache @@ -41,6 +47,12 @@ jobs: run: | cargo build --verbose ${{ matrix.features }} cargo test --tests --examples --verbose ${{ matrix.features }} + - name: Upload artifact + if: ${{ contains(matrix.features, '--features streams') }} + uses: actions/upload-artifact@v4 + with: + path: ./target/libmozjs-${{ matrix.platform.target }}.tar.gz + name: libmozjs-${{ matrix.platform.target }}.tar.gz linux: env: RUSTC_WRAPPER: "sccache" @@ -50,7 +62,7 @@ jobs: strategy: fail-fast: false matrix: - features: ["--features debugmozjs", ""] + features: ["--features debugmozjs", "--features streams"] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -65,17 +77,23 @@ jobs: cargo test --tests --examples --verbose ${{ matrix.features }} - name: Check wrappers integrity # we generate wrappers only without debugmozjs - if: ${{ matrix.features == '' }} + if: ${{ matrix.features == '--features streams' }} run: | bash ./mozjs/src/generate_wrappers.sh git diff --quiet --exit-code + - name: Upload artifact + if: ${{ contains(matrix.features, '--features streams') }} + uses: actions/upload-artifact@v4 + with: + path: ./target/libmozjs-x86_64-unknown-linux-gnu.tar.gz + name: libmozjs-x86_64-unknown-linux-gnu.tar.gz windows: runs-on: windows-latest strategy: fail-fast: false matrix: - features: ["--features debugmozjs", ""] + features: ["--features debugmozjs", "--features streams"] target: ["x86_64-pc-windows-msvc", "aarch64-pc-windows-msvc"] env: LINKER: "lld-link.exe" @@ -104,6 +122,12 @@ jobs: shell: cmd run: | cargo test --tests --examples --verbose --target ${{ matrix.target }} ${{ matrix.features }} + - name: Upload artifact + if: ${{ contains(matrix.features, '--features streams') }} + uses: actions/upload-artifact@v4 + with: + path: ./target/${{ matrix.target }}/libmozjs-x86_64-pc-windows-msvc.tar.gz + name: libmozjs-x86_64-pc-windows-msvc.tar.gz android: runs-on: ubuntu-latest @@ -178,3 +202,55 @@ jobs: - name: Mark the job as unsuccessful if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} run: exit 1 + + # create-release: + # runs-on: ubuntu-latest + # if: github.ref == 'refs/heads/main' && github.event_name == 'push' + # steps: + # - name: Create release + # id: create-release + # run: | + # NIGHTLY_TAG=$(date "+%F") + # RELEASE_URL=$(gh release create "${NIGHTLY_TAG}" \ + # --draft \ + # --title "${NIGHTLY_TAG}" \ + # --notes 'Version release based on servo/mozjs@${{ github.sha }}' \ + # --repo ${REPO}) + # TEMP_TAG=$(basename "$RELEASE_URL") + # RELEASE_ID=$( \ + # gh api -H "Accept: application/vnd.github+json" \ + # -H "X-GitHub-Api-Version: 2022-11-28" \ + # "/repos/${REPO}/releases/tags/${TEMP_TAG}" \ + # | jq '.id' \ + # ) + # echo "RELEASE_ID=${RELEASE_ID}" >> ${GITHUB_OUTPUT} + # outputs: + # release-id: ${{ steps.create-release.outputs.RELEASE_ID }} + + # publish-release: + # name: Result + # runs-on: ubuntu-latest + # needs: + # ["create-release", "mac", "linux", "windows"] + # if: github.ref == 'refs/heads/main' && github.event_name == 'push' + # env: + # RELEASE_ID: ${{ needs.create-release.outputs.release-id }} + # steps: + # - name: Publish as latest (success) + # if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} + # run: | + # gh api \ + # --method PATCH \ + # -H "Accept: application/vnd.github+json" \ + # -H "X-GitHub-Api-Version: 2022-11-28" \ + # /repos/${REPO}/releases/${RELEASE_ID} \ + # -F draft=false + # - name: Publish as latest (failure) + # if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} + # run: | + # gh api \ + # --method PATCH \ + # -H "Accept: application/vnd.github+json" \ + # -H "X-GitHub-Api-Version: 2022-11-28" \ + # /repos/${REPO}/releases/${RELEASE_ID} \ + # -F prerelease=true -F draft=false From 7c1b25af2917e9f1effb775fef18a23906916444 Mon Sep 17 00:00:00 2001 From: Wu Wayne Date: Thu, 29 Feb 2024 20:48:20 +0900 Subject: [PATCH 05/21] Add release steps --- .github/workflows/rust.yml | 139 +++++++++++++++++++++++-------------- 1 file changed, 85 insertions(+), 54 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 7e6f3c7c46a..6875ae423f7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -15,8 +15,8 @@ env: RUST_BACKTRACE: 1 SHELL: /bin/bash CARGO_INCREMENTAL: 0 - MOZJS_CREATE_ARCHIVE: 1 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + MOZJS_CREATE_ARCHIVE: 1 REPO: ${{ github.repository_owner }}/mozjs jobs: @@ -29,10 +29,12 @@ jobs: - { target: aarch64-apple-darwin, os: macos-14 } - { target: x86_64-apple-darwin, os: macos-13 } runs-on: ${{ matrix.platform.os }} + needs: create-draft-release env: RUSTC_WRAPPER: sccache CCACHE: sccache SCCACHE_GHA_ENABLED: "true" + RELEASE_ID: ${{ needs.create-draft-release.outputs.release-id }} steps: - uses: actions/checkout@v4 - name: Install deps @@ -53,12 +55,23 @@ jobs: with: path: ./target/libmozjs-${{ matrix.platform.target }}.tar.gz name: libmozjs-${{ matrix.platform.target }}.tar.gz + - name: Upload release asset + if: ${{ contains(matrix.features, '--features streams') && needs.create-draft-release.outputs.release-id != '' }} + uses: actions/upload-release-asset@v1 + with: + upload_url: https://uploads.github.com/repos/${{ github.repository_owner }}/mozjs/releases/${{ needs.create-draft-release.outputs.release-id }}/assets{?name,label} + asset_path: ./target/libmozjs-${{ matrix.platform.target }}.tar.gz + asset_name: libmozjs-${{ matrix.platform.target }}.tar.gz + asset_content_type: application/tar+gzip + linux: env: RUSTC_WRAPPER: "sccache" CCACHE: sccache SCCACHE_GHA_ENABLED: "true" + RELEASE_ID: ${{ needs.create-draft-release.outputs.release-id }} runs-on: ubuntu-latest + needs: create-draft-release strategy: fail-fast: false matrix: @@ -87,9 +100,18 @@ jobs: with: path: ./target/libmozjs-x86_64-unknown-linux-gnu.tar.gz name: libmozjs-x86_64-unknown-linux-gnu.tar.gz + - name: Upload release asset + if: ${{ contains(matrix.features, '--features streams') && needs.create-draft-release.outputs.release-id != '' }} + uses: actions/upload-release-asset@v1 + with: + upload_url: https://uploads.github.com/repos/${{ github.repository_owner }}/mozjs/releases/${{ needs.create-draft-release.outputs.release-id }}/assets{?name,label} + asset_path: ./target/libmozjs-x86_64-unknown-linux-gnu.tar.gz + asset_name: libmozjs-x86_64-unknown-linux-gnu.tar.gz + asset_content_type: application/tar+gzip windows: runs-on: windows-latest + needs: create-draft-release strategy: fail-fast: false matrix: @@ -102,6 +124,7 @@ jobs: MOZTOOLS_PATH: "${{ github.workspace }}\\target\\dependencies\\moztools-4.0" CCACHE: sccache SCCACHE_GHA_ENABLED: "true" + RELEASE_ID: ${{ needs.create-draft-release.outputs.release-id }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -128,6 +151,14 @@ jobs: with: path: ./target/${{ matrix.target }}/libmozjs-x86_64-pc-windows-msvc.tar.gz name: libmozjs-x86_64-pc-windows-msvc.tar.gz + - name: Upload release asset + if: ${{ !contains(matrix.target, 'aarch64') && contains(matrix.features, '--features streams') && needs.create-draft-release.outputs.release-id != '' }} + uses: actions/upload-release-asset@v1 + with: + upload_url: https://uploads.github.com/repos/${{ github.repository_owner }}/mozjs/releases/${{ needs.create-draft-release.outputs.release-id }}/assets{?name,label} + asset_path: ./target/${{ matrix.target }}/libmozjs-x86_64-pc-windows-msvc.tar.gz + asset_name: libmozjs-x86_64-pc-windows-msvc.tar.gz + asset_content_type: application/tar+gzip android: runs-on: ubuntu-latest @@ -189,11 +220,63 @@ jobs: run: | git diff --staged --no-ext-diff --quiet --exit-code + create-draft-release: + runs-on: ubuntu-latest + steps: + - name: Create draft release + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + id: create-release + run: | + NIGHTLY_TAG=$(date "+%F") + RELEASE_URL=$(gh release create "${NIGHTLY_TAG}" \ + --draft \ + --title "${NIGHTLY_TAG}" \ + --notes 'Version release based on servo/mozjs@${{ github.sha }}' \ + --repo ${REPO}) + TEMP_TAG=$(basename "$RELEASE_URL") + RELEASE_ID=$( \ + gh api -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + "/repos/${REPO}/releases/tags/${TEMP_TAG}" \ + | jq '.id' \ + ) + echo "RELEASE_ID=${RELEASE_ID}" >> ${GITHUB_OUTPUT} + outputs: + release-id: ${{ steps.create-release.outputs.RELEASE_ID }} + + publish-release: + name: Publish release + runs-on: ubuntu-latest + needs: + ["create-draft-release", "mac", "linux", "windows"] + env: + RELEASE_ID: ${{ needs.create-draft-release.outputs.release-id }} + steps: + - name: Publish as latest (success) + if: ${{ needs.create-draft-release.outputs.release-id != '' && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} + run: | + gh api \ + --method PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${REPO}/releases/${RELEASE_ID} \ + -F draft=false + - name: Publish as latest (failure) + if: ${{ needs.create-draft-release.outputs.release-id != '' && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }} + run: | + gh api \ + --method PATCH \ + -H "Accept: application/vnd.github+json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + /repos/${REPO}/releases/${RELEASE_ID} \ + -F prerelease=true -F draft=false + exit 1 + build_result: name: Result runs-on: ubuntu-latest needs: - ["android", "linux", "linux-cross-compile", "mac", "windows", "integrity"] + ["android", "linux", "linux-cross-compile", "mac", "windows", "integrity", "create-draft-release", "publish-release"] if: ${{ always() }} steps: - name: Mark the job as successful @@ -202,55 +285,3 @@ jobs: - name: Mark the job as unsuccessful if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} run: exit 1 - - # create-release: - # runs-on: ubuntu-latest - # if: github.ref == 'refs/heads/main' && github.event_name == 'push' - # steps: - # - name: Create release - # id: create-release - # run: | - # NIGHTLY_TAG=$(date "+%F") - # RELEASE_URL=$(gh release create "${NIGHTLY_TAG}" \ - # --draft \ - # --title "${NIGHTLY_TAG}" \ - # --notes 'Version release based on servo/mozjs@${{ github.sha }}' \ - # --repo ${REPO}) - # TEMP_TAG=$(basename "$RELEASE_URL") - # RELEASE_ID=$( \ - # gh api -H "Accept: application/vnd.github+json" \ - # -H "X-GitHub-Api-Version: 2022-11-28" \ - # "/repos/${REPO}/releases/tags/${TEMP_TAG}" \ - # | jq '.id' \ - # ) - # echo "RELEASE_ID=${RELEASE_ID}" >> ${GITHUB_OUTPUT} - # outputs: - # release-id: ${{ steps.create-release.outputs.RELEASE_ID }} - - # publish-release: - # name: Result - # runs-on: ubuntu-latest - # needs: - # ["create-release", "mac", "linux", "windows"] - # if: github.ref == 'refs/heads/main' && github.event_name == 'push' - # env: - # RELEASE_ID: ${{ needs.create-release.outputs.release-id }} - # steps: - # - name: Publish as latest (success) - # if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} - # run: | - # gh api \ - # --method PATCH \ - # -H "Accept: application/vnd.github+json" \ - # -H "X-GitHub-Api-Version: 2022-11-28" \ - # /repos/${REPO}/releases/${RELEASE_ID} \ - # -F draft=false - # - name: Publish as latest (failure) - # if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} - # run: | - # gh api \ - # --method PATCH \ - # -H "Accept: application/vnd.github+json" \ - # -H "X-GitHub-Api-Version: 2022-11-28" \ - # /repos/${REPO}/releases/${RELEASE_ID} \ - # -F prerelease=true -F draft=false From 83793f40e30f856168662dba8e1d55dfc8700737 Mon Sep 17 00:00:00 2001 From: Wu Wayne Date: Fri, 1 Mar 2024 15:21:58 +0900 Subject: [PATCH 06/21] Update widnow target arguments --- .github/workflows/rust.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 6875ae423f7..bf01825c083 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -116,7 +116,7 @@ jobs: fail-fast: false matrix: features: ["--features debugmozjs", "--features streams"] - target: ["x86_64-pc-windows-msvc", "aarch64-pc-windows-msvc"] + target: ["", "--target aarch64-pc-windows-msvc"] env: LINKER: "lld-link.exe" CC: "clang-cl" @@ -139,24 +139,24 @@ jobs: - name: Build Windows shell: cmd run: | - cargo build --verbose --target ${{ matrix.target }} ${{ matrix.features }} + cargo build --verbose ${{ matrix.target }} ${{ matrix.features }} - name: Test Windows if: ${{ !contains(matrix.target, 'aarch64') }} shell: cmd run: | - cargo test --tests --examples --verbose --target ${{ matrix.target }} ${{ matrix.features }} + cargo test --tests --examples --verbose ${{ matrix.target }} ${{ matrix.features }} - name: Upload artifact if: ${{ contains(matrix.features, '--features streams') }} uses: actions/upload-artifact@v4 with: - path: ./target/${{ matrix.target }}/libmozjs-x86_64-pc-windows-msvc.tar.gz + path: ./target/libmozjs-x86_64-pc-windows-msvc.tar.gz name: libmozjs-x86_64-pc-windows-msvc.tar.gz - name: Upload release asset if: ${{ !contains(matrix.target, 'aarch64') && contains(matrix.features, '--features streams') && needs.create-draft-release.outputs.release-id != '' }} uses: actions/upload-release-asset@v1 with: upload_url: https://uploads.github.com/repos/${{ github.repository_owner }}/mozjs/releases/${{ needs.create-draft-release.outputs.release-id }}/assets{?name,label} - asset_path: ./target/${{ matrix.target }}/libmozjs-x86_64-pc-windows-msvc.tar.gz + asset_path: ./target/libmozjs-x86_64-pc-windows-msvc.tar.gz asset_name: libmozjs-x86_64-pc-windows-msvc.tar.gz asset_content_type: application/tar+gzip From d150367589489ff324b883d7b84a84cbbdf0e81e Mon Sep 17 00:00:00 2001 From: Wu Yu Wei Date: Fri, 1 Mar 2024 19:03:15 +0900 Subject: [PATCH 07/21] Simplify release workflow --- .github/workflows/rust.yml | 102 +++++++------------------------------ 1 file changed, 17 insertions(+), 85 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bf01825c083..bf8ce367523 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -17,7 +17,6 @@ env: CARGO_INCREMENTAL: 0 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} MOZJS_CREATE_ARCHIVE: 1 - REPO: ${{ github.repository_owner }}/mozjs jobs: mac: @@ -29,12 +28,10 @@ jobs: - { target: aarch64-apple-darwin, os: macos-14 } - { target: x86_64-apple-darwin, os: macos-13 } runs-on: ${{ matrix.platform.os }} - needs: create-draft-release env: RUSTC_WRAPPER: sccache CCACHE: sccache SCCACHE_GHA_ENABLED: "true" - RELEASE_ID: ${{ needs.create-draft-release.outputs.release-id }} steps: - uses: actions/checkout@v4 - name: Install deps @@ -55,23 +52,13 @@ jobs: with: path: ./target/libmozjs-${{ matrix.platform.target }}.tar.gz name: libmozjs-${{ matrix.platform.target }}.tar.gz - - name: Upload release asset - if: ${{ contains(matrix.features, '--features streams') && needs.create-draft-release.outputs.release-id != '' }} - uses: actions/upload-release-asset@v1 - with: - upload_url: https://uploads.github.com/repos/${{ github.repository_owner }}/mozjs/releases/${{ needs.create-draft-release.outputs.release-id }}/assets{?name,label} - asset_path: ./target/libmozjs-${{ matrix.platform.target }}.tar.gz - asset_name: libmozjs-${{ matrix.platform.target }}.tar.gz - asset_content_type: application/tar+gzip linux: env: RUSTC_WRAPPER: "sccache" CCACHE: sccache SCCACHE_GHA_ENABLED: "true" - RELEASE_ID: ${{ needs.create-draft-release.outputs.release-id }} runs-on: ubuntu-latest - needs: create-draft-release strategy: fail-fast: false matrix: @@ -100,18 +87,9 @@ jobs: with: path: ./target/libmozjs-x86_64-unknown-linux-gnu.tar.gz name: libmozjs-x86_64-unknown-linux-gnu.tar.gz - - name: Upload release asset - if: ${{ contains(matrix.features, '--features streams') && needs.create-draft-release.outputs.release-id != '' }} - uses: actions/upload-release-asset@v1 - with: - upload_url: https://uploads.github.com/repos/${{ github.repository_owner }}/mozjs/releases/${{ needs.create-draft-release.outputs.release-id }}/assets{?name,label} - asset_path: ./target/libmozjs-x86_64-unknown-linux-gnu.tar.gz - asset_name: libmozjs-x86_64-unknown-linux-gnu.tar.gz - asset_content_type: application/tar+gzip windows: runs-on: windows-latest - needs: create-draft-release strategy: fail-fast: false matrix: @@ -124,7 +102,6 @@ jobs: MOZTOOLS_PATH: "${{ github.workspace }}\\target\\dependencies\\moztools-4.0" CCACHE: sccache SCCACHE_GHA_ENABLED: "true" - RELEASE_ID: ${{ needs.create-draft-release.outputs.release-id }} steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -146,19 +123,11 @@ jobs: run: | cargo test --tests --examples --verbose ${{ matrix.target }} ${{ matrix.features }} - name: Upload artifact - if: ${{ contains(matrix.features, '--features streams') }} + if: ${{ !contains(matrix.target, 'aarch64') && contains(matrix.features, '--features streams') }} uses: actions/upload-artifact@v4 with: path: ./target/libmozjs-x86_64-pc-windows-msvc.tar.gz name: libmozjs-x86_64-pc-windows-msvc.tar.gz - - name: Upload release asset - if: ${{ !contains(matrix.target, 'aarch64') && contains(matrix.features, '--features streams') && needs.create-draft-release.outputs.release-id != '' }} - uses: actions/upload-release-asset@v1 - with: - upload_url: https://uploads.github.com/repos/${{ github.repository_owner }}/mozjs/releases/${{ needs.create-draft-release.outputs.release-id }}/assets{?name,label} - asset_path: ./target/libmozjs-x86_64-pc-windows-msvc.tar.gz - asset_name: libmozjs-x86_64-pc-windows-msvc.tar.gz - asset_content_type: application/tar+gzip android: runs-on: ubuntu-latest @@ -220,63 +189,11 @@ jobs: run: | git diff --staged --no-ext-diff --quiet --exit-code - create-draft-release: - runs-on: ubuntu-latest - steps: - - name: Create draft release - if: github.ref == 'refs/heads/main' && github.event_name == 'push' - id: create-release - run: | - NIGHTLY_TAG=$(date "+%F") - RELEASE_URL=$(gh release create "${NIGHTLY_TAG}" \ - --draft \ - --title "${NIGHTLY_TAG}" \ - --notes 'Version release based on servo/mozjs@${{ github.sha }}' \ - --repo ${REPO}) - TEMP_TAG=$(basename "$RELEASE_URL") - RELEASE_ID=$( \ - gh api -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - "/repos/${REPO}/releases/tags/${TEMP_TAG}" \ - | jq '.id' \ - ) - echo "RELEASE_ID=${RELEASE_ID}" >> ${GITHUB_OUTPUT} - outputs: - release-id: ${{ steps.create-release.outputs.RELEASE_ID }} - - publish-release: - name: Publish release - runs-on: ubuntu-latest - needs: - ["create-draft-release", "mac", "linux", "windows"] - env: - RELEASE_ID: ${{ needs.create-draft-release.outputs.release-id }} - steps: - - name: Publish as latest (success) - if: ${{ needs.create-draft-release.outputs.release-id != '' && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} - run: | - gh api \ - --method PATCH \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - /repos/${REPO}/releases/${RELEASE_ID} \ - -F draft=false - - name: Publish as latest (failure) - if: ${{ needs.create-draft-release.outputs.release-id != '' && (contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')) }} - run: | - gh api \ - --method PATCH \ - -H "Accept: application/vnd.github+json" \ - -H "X-GitHub-Api-Version: 2022-11-28" \ - /repos/${REPO}/releases/${RELEASE_ID} \ - -F prerelease=true -F draft=false - exit 1 - build_result: name: Result runs-on: ubuntu-latest needs: - ["android", "linux", "linux-cross-compile", "mac", "windows", "integrity", "create-draft-release", "publish-release"] + ["android", "linux", "linux-cross-compile", "mac", "windows", "integrity"] if: ${{ always() }} steps: - name: Mark the job as successful @@ -285,3 +202,18 @@ jobs: - name: Mark the job as unsuccessful if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} run: exit 1 + + publish-release: + name: Publish release + runs-on: ubuntu-latest + needs: build_result + if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + merge-multiple: true + - name: Publish release + run: | + RELEASE_TAG=$(date "+%F") + gh release create ${RELEASE_TAG} ./*.tar.gz From 0b3f0b5ca70472fc497293211f87debe01d63c1c Mon Sep 17 00:00:00 2001 From: Wu Wayne Date: Sat, 2 Mar 2024 19:50:58 +0900 Subject: [PATCH 08/21] Add release check CI --- .github/workflows/release.yml | 123 ++++++++++++++++++++++++++++++++++ .github/workflows/rust.yml | 16 ++++- 2 files changed, 137 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000000..b7be49783c1 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,123 @@ + +name: Version Release Check + +on: + workflow_call: + inputs: + release-tag: + required: true + type: string + +env: + RUST_BACKTRACE: 1 + SHELL: /bin/bash + CARGO_INCREMENTAL: 0 + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + REPO: ${{ github.repository_owner }}/mozjs + MOZJS_ARCHIVE: libmozjs.tar.gz + +jobs: + mac: + strategy: + fail-fast: false + matrix: + features: ["--features streams"] + platform: + - { target: aarch64-apple-darwin, os: macos-14 } + - { target: x86_64-apple-darwin, os: macos-13 } + runs-on: ${{ matrix.platform.os }} + env: + RUSTC_WRAPPER: sccache + CCACHE: sccache + SCCACHE_GHA_ENABLED: "true" + steps: + - uses: actions/checkout@v4 + - name: Install deps + run: | + # Unlink and re-link to prevent errors when github mac runner images + # https://github.com/actions/setup-python/issues/577 + brew list -1 | grep python | while read formula; do brew unlink $formula; brew link --overwrite $formula; done + brew install llvm yasm + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Download prebuilt mozjs + run: | + curl -L https://github.com/${REPO}/releases/download/${{ inputs.release-tag }}/libmozjs-${{ matrix.platform.target }}.tar.gz -o libmozjs.tar.gz + - name: Build + run: | + cargo build --verbose ${{ matrix.features }} + cargo test --tests --examples --verbose ${{ matrix.features }} + + linux: + env: + RUSTC_WRAPPER: "sccache" + CCACHE: sccache + SCCACHE_GHA_ENABLED: "true" + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + features: ["--features streams"] + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + - name: Install deps + run: | + sudo apt install llvm -y + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Download prebuilt mozjs + run: | + curl -L https://github.com/${REPO}/releases/download/${{ inputs.release-tag }}/libmozjs-x86_64-unknown-linux-gnu.tar.gz -o libmozjs.tar.gz + - name: Build + run: | + cargo build --verbose ${{ matrix.features }} + cargo test --tests --examples --verbose ${{ matrix.features }} + + windows: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + features: ["--features streams"] + env: + LINKER: "lld-link.exe" + CC: "clang-cl" + CXX: "clang-cl" + MOZTOOLS_PATH: "${{ github.workspace }}\\target\\dependencies\\moztools-4.0" + CCACHE: sccache + SCCACHE_GHA_ENABLED: "true" + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.target }} + - name: Install deps + run: | + curl -SL "https://github.com/servo/servo-build-deps/releases/download/msvc-deps/moztools-4.0.zip" --create-dirs -o target/dependencies/moztools.zip + cd target/dependencies && unzip -qo moztools.zip -d . + - name: Run sccache-cache + uses: mozilla-actions/sccache-action@v0.0.3 + - name: Download prebuilt mozjs + run: | + curl -L https://github.com/${{ github.repository_owner }}/mozjs/releases/download/${{ inputs.release-tag }}/libmozjs-x86_64-pc-windows-msvc.tar.gz -o libmozjs.tar.gz + - name: Build Windows + shell: cmd + run: | + cargo build --verbose ${{ matrix.features }} + cargo test --tests --examples --verbose ${{ matrix.features }} + + build_result: + name: Result + runs-on: ubuntu-latest + needs: + ["linux", "mac", "windows"] + if: ${{ always() }} + steps: + - name: Mark the job as successful + if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} + run: exit 0 + - name: Mark the job as unsuccessful + if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} + run: exit 1 + diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index bf8ce367523..98293bbfb41 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -213,7 +213,19 @@ jobs: - uses: actions/download-artifact@v4 with: merge-multiple: true - - name: Publish release + - id: release run: | - RELEASE_TAG=$(date "+%F") + RELEASE_TAG=$(date "+%F-%H-%M") gh release create ${RELEASE_TAG} ./*.tar.gz + echo "RELEASE_TAG=${RELEASE_TAG}" >> ${GITHUB_OUTPUT} + outputs: + release-tag: ${{ steps.release.outputs.RELEASE_TAG }} + + verify-release: + name: Verify release + needs: publish-release + if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} + uses: ./.github/workflows/release.yml + with: + release-tag: ${{ needs.publish-release.outputs.release-tag }} + From 9790c30f183fd4d8186192814e925ddf6827f913 Mon Sep 17 00:00:00 2001 From: Wu Yu Wei Date: Mon, 4 Mar 2024 12:08:16 +0900 Subject: [PATCH 09/21] Update trigger condition and remove deps --- .github/workflows/release.yml | 61 ++++++++++++++--------------------- 1 file changed, 24 insertions(+), 37 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7be49783c1..07bceaff254 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,6 +2,9 @@ name: Version Release Check on: + pull_request: + release: + types: [published] workflow_call: inputs: release-tag: @@ -17,6 +20,21 @@ env: MOZJS_ARCHIVE: libmozjs.tar.gz jobs: + release-tag: + runs-on: ubuntu-latest + steps: + - id: tag-name + run: | + if [[ ${{ github.event_name }} == 'workflow_call' ]]; then + echo "RELEASE_TAG=${{ inputs.release-tag }}" >> ${GITHUB_OUTPUT} + elif [[ ${{ github.event_name }} == 'release' ]]; then + echo "RELEASE_TAG=${{ github.ref_name }}" >> ${GITHUB_OUTPUT} + else + echo "RELEASE_TAG='2024-03-02-06-57'" >> ${GITHUB_OUTPUT} + fi + outputs: + release-tag: ${{ steps.tag-name.outputs.RELEASE_TAG }} + mac: strategy: fail-fast: false @@ -26,34 +44,20 @@ jobs: - { target: aarch64-apple-darwin, os: macos-14 } - { target: x86_64-apple-darwin, os: macos-13 } runs-on: ${{ matrix.platform.os }} - env: - RUSTC_WRAPPER: sccache - CCACHE: sccache - SCCACHE_GHA_ENABLED: "true" + needs: release-tag steps: - uses: actions/checkout@v4 - - name: Install deps - run: | - # Unlink and re-link to prevent errors when github mac runner images - # https://github.com/actions/setup-python/issues/577 - brew list -1 | grep python | while read formula; do brew unlink $formula; brew link --overwrite $formula; done - brew install llvm yasm - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 - name: Download prebuilt mozjs run: | - curl -L https://github.com/${REPO}/releases/download/${{ inputs.release-tag }}/libmozjs-${{ matrix.platform.target }}.tar.gz -o libmozjs.tar.gz + curl -L https://github.com/${REPO}/releases/download/${{ needs.release-tag.outputs.release-tag }}/libmozjs-${{ matrix.platform.target }}.tar.gz -o libmozjs.tar.gz - name: Build run: | cargo build --verbose ${{ matrix.features }} cargo test --tests --examples --verbose ${{ matrix.features }} linux: - env: - RUSTC_WRAPPER: "sccache" - CCACHE: sccache - SCCACHE_GHA_ENABLED: "true" runs-on: ubuntu-latest + needs: release-tag strategy: fail-fast: false matrix: @@ -61,14 +65,9 @@ jobs: steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable - - name: Install deps - run: | - sudo apt install llvm -y - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 - name: Download prebuilt mozjs run: | - curl -L https://github.com/${REPO}/releases/download/${{ inputs.release-tag }}/libmozjs-x86_64-unknown-linux-gnu.tar.gz -o libmozjs.tar.gz + curl -L https://github.com/${REPO}/releases/download/${{ needs.release-tag.outputs.release-tag }}/libmozjs-x86_64-unknown-linux-gnu.tar.gz -o libmozjs.tar.gz - name: Build run: | cargo build --verbose ${{ matrix.features }} @@ -76,31 +75,19 @@ jobs: windows: runs-on: windows-latest + needs: release-tag strategy: fail-fast: false matrix: features: ["--features streams"] - env: - LINKER: "lld-link.exe" - CC: "clang-cl" - CXX: "clang-cl" - MOZTOOLS_PATH: "${{ github.workspace }}\\target\\dependencies\\moztools-4.0" - CCACHE: sccache - SCCACHE_GHA_ENABLED: "true" steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: targets: ${{ matrix.target }} - - name: Install deps - run: | - curl -SL "https://github.com/servo/servo-build-deps/releases/download/msvc-deps/moztools-4.0.zip" --create-dirs -o target/dependencies/moztools.zip - cd target/dependencies && unzip -qo moztools.zip -d . - - name: Run sccache-cache - uses: mozilla-actions/sccache-action@v0.0.3 - name: Download prebuilt mozjs run: | - curl -L https://github.com/${{ github.repository_owner }}/mozjs/releases/download/${{ inputs.release-tag }}/libmozjs-x86_64-pc-windows-msvc.tar.gz -o libmozjs.tar.gz + curl -L https://github.com/${{ github.repository_owner }}/mozjs/releases/download/${{ needs.release-tag.outputs.release-tag }}/libmozjs-x86_64-pc-windows-msvc.tar.gz -o libmozjs.tar.gz - name: Build Windows shell: cmd run: | From 2e0efed7db9da5333135729c57879aa54a4a4d1c Mon Sep 17 00:00:00 2001 From: Wu Yu Wei Date: Mon, 4 Mar 2024 13:12:25 +0900 Subject: [PATCH 10/21] Add CARGO_TARGET_DIR on Windows job --- .github/workflows/release.yml | 7 ++----- .github/workflows/rust.yml | 8 ++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 07bceaff254..684be70427b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -2,7 +2,6 @@ name: Version Release Check on: - pull_request: release: types: [published] workflow_call: @@ -25,12 +24,10 @@ jobs: steps: - id: tag-name run: | - if [[ ${{ github.event_name }} == 'workflow_call' ]]; then + if [[ '${{ inputs.release-tag }}' != '' ]]; then echo "RELEASE_TAG=${{ inputs.release-tag }}" >> ${GITHUB_OUTPUT} - elif [[ ${{ github.event_name }} == 'release' ]]; then + elif [[ '${{ github.event_name }}' == 'release' ]]; then echo "RELEASE_TAG=${{ github.ref_name }}" >> ${GITHUB_OUTPUT} - else - echo "RELEASE_TAG='2024-03-02-06-57'" >> ${GITHUB_OUTPUT} fi outputs: release-tag: ${{ steps.tag-name.outputs.RELEASE_TAG }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 98293bbfb41..0a6a206e958 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -94,7 +94,7 @@ jobs: fail-fast: false matrix: features: ["--features debugmozjs", "--features streams"] - target: ["", "--target aarch64-pc-windows-msvc"] + target: ["x86_64-pc-windows-msvc", "aarch64-pc-windows-msvc"] env: LINKER: "lld-link.exe" CC: "clang-cl" @@ -116,17 +116,17 @@ jobs: - name: Build Windows shell: cmd run: | - cargo build --verbose ${{ matrix.target }} ${{ matrix.features }} + cargo build --verbose --target ${{ matrix.target }} ${{ matrix.features }} - name: Test Windows if: ${{ !contains(matrix.target, 'aarch64') }} shell: cmd run: | - cargo test --tests --examples --verbose ${{ matrix.target }} ${{ matrix.features }} + cargo test --tests --examples --verbose --target ${{ matrix.target }} ${{ matrix.features }} - name: Upload artifact if: ${{ !contains(matrix.target, 'aarch64') && contains(matrix.features, '--features streams') }} uses: actions/upload-artifact@v4 with: - path: ./target/libmozjs-x86_64-pc-windows-msvc.tar.gz + path: ./target/${{ matrix.target }}/libmozjs-x86_64-pc-windows-msvc.tar.gz name: libmozjs-x86_64-pc-windows-msvc.tar.gz android: From a8370a34239b695486d5ace77f36b4535a3759ec Mon Sep 17 00:00:00 2001 From: Wu Yu Wei Date: Mon, 4 Mar 2024 15:08:37 +0900 Subject: [PATCH 11/21] Merge all jobs in release into one --- .github/workflows/release.yml | 65 +++-------------------------------- .github/workflows/rust.yml | 5 +-- 2 files changed, 8 insertions(+), 62 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 684be70427b..03b9390d3aa 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,8 +14,6 @@ env: RUST_BACKTRACE: 1 SHELL: /bin/bash CARGO_INCREMENTAL: 0 - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - REPO: ${{ github.repository_owner }}/mozjs MOZJS_ARCHIVE: libmozjs.tar.gz jobs: @@ -32,76 +30,23 @@ jobs: outputs: release-tag: ${{ steps.tag-name.outputs.RELEASE_TAG }} - mac: + verify-artifact: strategy: fail-fast: false matrix: - features: ["--features streams"] platform: - { target: aarch64-apple-darwin, os: macos-14 } - { target: x86_64-apple-darwin, os: macos-13 } + - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest } + - { target: x86_64-pc-windows-msvc, os: windows-latest } runs-on: ${{ matrix.platform.os }} needs: release-tag steps: - uses: actions/checkout@v4 - name: Download prebuilt mozjs run: | - curl -L https://github.com/${REPO}/releases/download/${{ needs.release-tag.outputs.release-tag }}/libmozjs-${{ matrix.platform.target }}.tar.gz -o libmozjs.tar.gz + curl -L https://github.com/${{ github.repository_owner }}/mozjs/releases/download/${{ needs.release-tag.outputs.release-tag }}/libmozjs-${{ matrix.platform.target }}.tar.gz -o libmozjs.tar.gz - name: Build run: | - cargo build --verbose ${{ matrix.features }} + cargo build --verbose --features streams cargo test --tests --examples --verbose ${{ matrix.features }} - - linux: - runs-on: ubuntu-latest - needs: release-tag - strategy: - fail-fast: false - matrix: - features: ["--features streams"] - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - - name: Download prebuilt mozjs - run: | - curl -L https://github.com/${REPO}/releases/download/${{ needs.release-tag.outputs.release-tag }}/libmozjs-x86_64-unknown-linux-gnu.tar.gz -o libmozjs.tar.gz - - name: Build - run: | - cargo build --verbose ${{ matrix.features }} - cargo test --tests --examples --verbose ${{ matrix.features }} - - windows: - runs-on: windows-latest - needs: release-tag - strategy: - fail-fast: false - matrix: - features: ["--features streams"] - steps: - - uses: actions/checkout@v4 - - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.target }} - - name: Download prebuilt mozjs - run: | - curl -L https://github.com/${{ github.repository_owner }}/mozjs/releases/download/${{ needs.release-tag.outputs.release-tag }}/libmozjs-x86_64-pc-windows-msvc.tar.gz -o libmozjs.tar.gz - - name: Build Windows - shell: cmd - run: | - cargo build --verbose ${{ matrix.features }} - cargo test --tests --examples --verbose ${{ matrix.features }} - - build_result: - name: Result - runs-on: ubuntu-latest - needs: - ["linux", "mac", "windows"] - if: ${{ always() }} - steps: - - name: Mark the job as successful - if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} - run: exit 0 - - name: Mark the job as unsuccessful - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} - run: exit 1 - diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0a6a206e958..08a47346ead 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -193,7 +193,7 @@ jobs: name: Result runs-on: ubuntu-latest needs: - ["android", "linux", "linux-cross-compile", "mac", "windows", "integrity"] + ["android", "linux", "linux-cross-compile", "mac", "windows", "integrity", "publish-release", "verify-release"] if: ${{ always() }} steps: - name: Mark the job as successful @@ -206,7 +206,8 @@ jobs: publish-release: name: Publish release runs-on: ubuntu-latest - needs: build_result + needs: + ["linux", "mac", "windows"] if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} steps: - uses: actions/checkout@v4 From d84ff44f512503d0947637fc5a97601769d69397 Mon Sep 17 00:00:00 2001 From: Wu Wayne Date: Mon, 4 Mar 2024 18:21:36 +0900 Subject: [PATCH 12/21] Check from artifact as well --- .github/workflows/release.yml | 8 +++++++- .github/workflows/rust.yml | 3 ++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 03b9390d3aa..12fc9f0fa83 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -43,7 +43,13 @@ jobs: needs: release-tag steps: - uses: actions/checkout@v4 - - name: Download prebuilt mozjs + - name: Download prebuilt mozjs from artifact + if: ${{ needs.release-tag.outputs.release-tag == '' }} + uses: actions/download-artifact@v4 + with: + name: libmozjs-${{ matrix.platform.target }}.tar.gz + - name: Download prebuilt mozjs from release + if: ${{ needs.release-tag.outputs.release-tag != '' }} run: | curl -L https://github.com/${{ github.repository_owner }}/mozjs/releases/download/${{ needs.release-tag.outputs.release-tag }}/libmozjs-${{ matrix.platform.target }}.tar.gz -o libmozjs.tar.gz - name: Build diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 08a47346ead..0bdf5e83927 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -208,13 +208,14 @@ jobs: runs-on: ubuntu-latest needs: ["linux", "mac", "windows"] - if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} + if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: merge-multiple: true - id: release + if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} run: | RELEASE_TAG=$(date "+%F-%H-%M") gh release create ${RELEASE_TAG} ./*.tar.gz From 3800976bd1dbe84fb9026f7b2fc009e2d31a6f77 Mon Sep 17 00:00:00 2001 From: Wu Wayne Date: Mon, 4 Mar 2024 18:45:43 +0900 Subject: [PATCH 13/21] Extract --features --- .github/workflows/rust.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 0bdf5e83927..78cee25c40d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -23,7 +23,7 @@ jobs: strategy: fail-fast: false matrix: - features: ["--features debugmozjs", "--features streams"] + features: ["debugmozjs", "streams"] platform: - { target: aarch64-apple-darwin, os: macos-14 } - { target: x86_64-apple-darwin, os: macos-13 } @@ -44,10 +44,10 @@ jobs: uses: mozilla-actions/sccache-action@v0.0.3 - name: Build run: | - cargo build --verbose ${{ matrix.features }} - cargo test --tests --examples --verbose ${{ matrix.features }} + cargo build --verbose --features ${{ matrix.features }} + cargo test --tests --examples --verbose --features ${{ matrix.features }} - name: Upload artifact - if: ${{ contains(matrix.features, '--features streams') }} + if: ${{ contains(matrix.features, 'streams') }} uses: actions/upload-artifact@v4 with: path: ./target/libmozjs-${{ matrix.platform.target }}.tar.gz @@ -62,7 +62,7 @@ jobs: strategy: fail-fast: false matrix: - features: ["--features debugmozjs", "--features streams"] + features: ["debugmozjs", "streams"] steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable @@ -73,16 +73,16 @@ jobs: uses: mozilla-actions/sccache-action@v0.0.3 - name: Build run: | - cargo build --verbose ${{ matrix.features }} - cargo test --tests --examples --verbose ${{ matrix.features }} + cargo build --verbose --features ${{ matrix.features }} + cargo test --tests --examples --verbose --features ${{ matrix.features }} - name: Check wrappers integrity # we generate wrappers only without debugmozjs - if: ${{ matrix.features == '--features streams' }} + if: ${{ matrix.features == 'streams' }} run: | bash ./mozjs/src/generate_wrappers.sh git diff --quiet --exit-code - name: Upload artifact - if: ${{ contains(matrix.features, '--features streams') }} + if: ${{ contains(matrix.features, 'streams') }} uses: actions/upload-artifact@v4 with: path: ./target/libmozjs-x86_64-unknown-linux-gnu.tar.gz @@ -93,7 +93,7 @@ jobs: strategy: fail-fast: false matrix: - features: ["--features debugmozjs", "--features streams"] + features: ["debugmozjs", "streams"] target: ["x86_64-pc-windows-msvc", "aarch64-pc-windows-msvc"] env: LINKER: "lld-link.exe" @@ -116,14 +116,14 @@ jobs: - name: Build Windows shell: cmd run: | - cargo build --verbose --target ${{ matrix.target }} ${{ matrix.features }} + cargo build --verbose --target ${{ matrix.target }} --features ${{ matrix.features }} - name: Test Windows if: ${{ !contains(matrix.target, 'aarch64') }} shell: cmd run: | - cargo test --tests --examples --verbose --target ${{ matrix.target }} ${{ matrix.features }} + cargo test --tests --examples --verbose --target ${{ matrix.target }} --features ${{ matrix.features }} - name: Upload artifact - if: ${{ !contains(matrix.target, 'aarch64') && contains(matrix.features, '--features streams') }} + if: ${{ !contains(matrix.target, 'aarch64') && contains(matrix.features, 'streams') }} uses: actions/upload-artifact@v4 with: path: ./target/${{ matrix.target }}/libmozjs-x86_64-pc-windows-msvc.tar.gz From dee33e66b2bef14bfe482c2e4e1d80035ebf294a Mon Sep 17 00:00:00 2001 From: Wu Wayne Date: Mon, 4 Mar 2024 19:15:41 +0900 Subject: [PATCH 14/21] Rename MOZJS_ARCHIVE path --- .github/workflows/release.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 12fc9f0fa83..8ebc6e7b0f2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,10 +14,9 @@ env: RUST_BACKTRACE: 1 SHELL: /bin/bash CARGO_INCREMENTAL: 0 - MOZJS_ARCHIVE: libmozjs.tar.gz jobs: - release-tag: + release: runs-on: ubuntu-latest steps: - id: tag-name @@ -28,7 +27,7 @@ jobs: echo "RELEASE_TAG=${{ github.ref_name }}" >> ${GITHUB_OUTPUT} fi outputs: - release-tag: ${{ steps.tag-name.outputs.RELEASE_TAG }} + tag: ${{ steps.tag-name.outputs.RELEASE_TAG }} verify-artifact: strategy: @@ -40,18 +39,20 @@ jobs: - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest } - { target: x86_64-pc-windows-msvc, os: windows-latest } runs-on: ${{ matrix.platform.os }} - needs: release-tag + needs: release + env: + MOZJS_ARCHIVE: libmozjs-${{ matrix.platform.target }}.tar.gz steps: - uses: actions/checkout@v4 - name: Download prebuilt mozjs from artifact - if: ${{ needs.release-tag.outputs.release-tag == '' }} + if: ${{ needs.release.outputs.tag == '' }} uses: actions/download-artifact@v4 with: name: libmozjs-${{ matrix.platform.target }}.tar.gz - name: Download prebuilt mozjs from release - if: ${{ needs.release-tag.outputs.release-tag != '' }} + if: ${{ needs.release.outputs.tag != '' }} run: | - curl -L https://github.com/${{ github.repository_owner }}/mozjs/releases/download/${{ needs.release-tag.outputs.release-tag }}/libmozjs-${{ matrix.platform.target }}.tar.gz -o libmozjs.tar.gz + curl -L https://github.com/${{ github.repository_owner }}/mozjs/releases/download/${{ needs.release.outputs.tag }}/libmozjs-${{ matrix.platform.target }}.tar.gz -o libmozjs-${{ matrix.platform.target }}.tar.gz - name: Build run: | cargo build --verbose --features streams From 94afc620340baf22cb4c18c2571a2ecd7f1a04de Mon Sep 17 00:00:00 2001 From: Wu Wayne Date: Mon, 4 Mar 2024 21:35:30 +0900 Subject: [PATCH 15/21] Fix missed matrix.features --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8ebc6e7b0f2..9697f50cd2e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -56,4 +56,4 @@ jobs: - name: Build run: | cargo build --verbose --features streams - cargo test --tests --examples --verbose ${{ matrix.features }} + cargo test --tests --examples --verbose --features streams From 713e84eb998873291cd8cadf7ffdfead504bdfd3 Mon Sep 17 00:00:00 2001 From: Wu Wayne Date: Tue, 5 Mar 2024 15:12:44 +0900 Subject: [PATCH 16/21] Update release jobs --- .github/workflows/release.yml | 23 +++++------------------ .github/workflows/rust.yml | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 32 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9697f50cd2e..0cfc2a6f3b2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -16,20 +16,7 @@ env: CARGO_INCREMENTAL: 0 jobs: - release: - runs-on: ubuntu-latest - steps: - - id: tag-name - run: | - if [[ '${{ inputs.release-tag }}' != '' ]]; then - echo "RELEASE_TAG=${{ inputs.release-tag }}" >> ${GITHUB_OUTPUT} - elif [[ '${{ github.event_name }}' == 'release' ]]; then - echo "RELEASE_TAG=${{ github.ref_name }}" >> ${GITHUB_OUTPUT} - fi - outputs: - tag: ${{ steps.tag-name.outputs.RELEASE_TAG }} - - verify-artifact: + verify-archive: strategy: fail-fast: false matrix: @@ -39,20 +26,20 @@ jobs: - { target: x86_64-unknown-linux-gnu, os: ubuntu-latest } - { target: x86_64-pc-windows-msvc, os: windows-latest } runs-on: ${{ matrix.platform.os }} - needs: release env: + RELEASE_TAG: ${{ github.event_name == 'release' && github.ref_name || inputs.release-tag }} MOZJS_ARCHIVE: libmozjs-${{ matrix.platform.target }}.tar.gz steps: - uses: actions/checkout@v4 - name: Download prebuilt mozjs from artifact - if: ${{ needs.release.outputs.tag == '' }} + if: ${{ env.RELEASE_TAG == '' }} uses: actions/download-artifact@v4 with: name: libmozjs-${{ matrix.platform.target }}.tar.gz - name: Download prebuilt mozjs from release - if: ${{ needs.release.outputs.tag != '' }} + if: ${{ env.RELEASE_TAG != '' }} run: | - curl -L https://github.com/${{ github.repository_owner }}/mozjs/releases/download/${{ needs.release.outputs.tag }}/libmozjs-${{ matrix.platform.target }}.tar.gz -o libmozjs-${{ matrix.platform.target }}.tar.gz + curl -L https://github.com/${{ github.repository_owner }}/mozjs/releases/download/${{ env.RELEASE_TAG }}/libmozjs-${{ matrix.platform.target }}.tar.gz -o libmozjs-${{ matrix.platform.target }}.tar.gz - name: Build run: | cargo build --verbose --features streams diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 78cee25c40d..08dc0df7fb1 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -189,20 +189,6 @@ jobs: run: | git diff --staged --no-ext-diff --quiet --exit-code - build_result: - name: Result - runs-on: ubuntu-latest - needs: - ["android", "linux", "linux-cross-compile", "mac", "windows", "integrity", "publish-release", "verify-release"] - if: ${{ always() }} - steps: - - name: Mark the job as successful - if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} - run: exit 0 - - name: Mark the job as unsuccessful - if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} - run: exit 1 - publish-release: name: Publish release runs-on: ubuntu-latest @@ -231,3 +217,17 @@ jobs: with: release-tag: ${{ needs.publish-release.outputs.release-tag }} + build_result: + name: Result + runs-on: ubuntu-latest + needs: + ["android", "linux", "linux-cross-compile", "mac", "windows", "integrity", "publish-release", "verify-release"] + if: ${{ always() }} + steps: + - name: Mark the job as successful + if: ${{ !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} + run: exit 0 + - name: Mark the job as unsuccessful + if: ${{ contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') }} + run: exit 1 + From b154d0a8b8d6a034c30893b28b44493b3246bdc9 Mon Sep 17 00:00:00 2001 From: Wu Wayne Date: Wed, 6 Mar 2024 14:21:52 +0900 Subject: [PATCH 17/21] Update release tag name and check if exist before release --- .github/workflows/rust.yml | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 08dc0df7fb1..9dc39bca71d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -190,7 +190,7 @@ jobs: git diff --staged --no-ext-diff --quiet --exit-code publish-release: - name: Publish release + name: Check version and publish release runs-on: ubuntu-latest needs: ["linux", "mac", "windows"] @@ -200,14 +200,19 @@ jobs: - uses: actions/download-artifact@v4 with: merge-multiple: true - - id: release + - id: check-tag if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} run: | - RELEASE_TAG=$(date "+%F-%H-%M") - gh release create ${RELEASE_TAG} ./*.tar.gz + RELEASE_TAG=mozjs-sys-v$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "mozjs_sys") | .version') + if git show-ref --tags --verify --quiet "refs/tags/${RELEASE_TAG}"; then + RELEASE_TAG='' + fi echo "RELEASE_TAG=${RELEASE_TAG}" >> ${GITHUB_OUTPUT} + - name: Publish release + if: ${{ steps.check-tag.outputs.RELEASE_TAG != '' }} + run: gh release create ${{ steps.check-tag.outputs.RELEASE_TAG }} ./*.tar.gz outputs: - release-tag: ${{ steps.release.outputs.RELEASE_TAG }} + release-tag: ${{ steps.check-tag.outputs.RELEASE_TAG }} verify-release: name: Verify release From 8d7ed20ee2ce2e11d7e22e032394122650ca3973 Mon Sep 17 00:00:00 2001 From: Wu Yu Wei Date: Sat, 9 Mar 2024 15:34:25 +0900 Subject: [PATCH 18/21] Update release job to check remote tags --- .github/workflows/rust.yml | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 9dc39bca71d..a57f8ba87ef 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -200,17 +200,16 @@ jobs: - uses: actions/download-artifact@v4 with: merge-multiple: true - - id: check-tag + - name: Publish release if tag doesn't exist + id: check-tag if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} run: | RELEASE_TAG=mozjs-sys-v$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "mozjs_sys") | .version') - if git show-ref --tags --verify --quiet "refs/tags/${RELEASE_TAG}"; then - RELEASE_TAG='' - fi + git fetch --tags --quiet + if ! git show-ref --tags --verify --quiet "refs/tags/${RELEASE_TAG}" ; then + gh release create ${{ steps.check-tag.outputs.RELEASE_TAG }} ./*.tar.gz + fi echo "RELEASE_TAG=${RELEASE_TAG}" >> ${GITHUB_OUTPUT} - - name: Publish release - if: ${{ steps.check-tag.outputs.RELEASE_TAG != '' }} - run: gh release create ${{ steps.check-tag.outputs.RELEASE_TAG }} ./*.tar.gz outputs: release-tag: ${{ steps.check-tag.outputs.RELEASE_TAG }} From fb6869e3c2f99f2d7a36ce82fdc7efae75761fcf Mon Sep 17 00:00:00 2001 From: Wu Yu Wei Date: Sat, 9 Mar 2024 15:42:22 +0900 Subject: [PATCH 19/21] Simplify release job steps instead --- .github/workflows/rust.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a57f8ba87ef..1bde42f3a74 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -200,16 +200,14 @@ jobs: - uses: actions/download-artifact@v4 with: merge-multiple: true - - name: Publish release if tag doesn't exist - id: check-tag + - id: check-tag if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} run: | RELEASE_TAG=mozjs-sys-v$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "mozjs_sys") | .version') - git fetch --tags --quiet - if ! git show-ref --tags --verify --quiet "refs/tags/${RELEASE_TAG}" ; then - gh release create ${{ steps.check-tag.outputs.RELEASE_TAG }} ./*.tar.gz - fi echo "RELEASE_TAG=${RELEASE_TAG}" >> ${GITHUB_OUTPUT} + - name: Publish release + if: ${{ steps.check-tag.outputs.RELEASE_TAG != '' }} + run: gh release create ${{ steps.check-tag.outputs.RELEASE_TAG }} ./*.tar.gz || exit 0 outputs: release-tag: ${{ steps.check-tag.outputs.RELEASE_TAG }} From a58bfe9bb0099fa87c691947382c1dfe18c9cd01 Mon Sep 17 00:00:00 2001 From: Wu Yu Wei Date: Sat, 9 Mar 2024 15:50:13 +0900 Subject: [PATCH 20/21] Revert latest commit --- .github/workflows/rust.yml | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 1bde42f3a74..a57f8ba87ef 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -200,14 +200,16 @@ jobs: - uses: actions/download-artifact@v4 with: merge-multiple: true - - id: check-tag + - name: Publish release if tag doesn't exist + id: check-tag if: ${{ github.ref == 'refs/heads/main' && github.event_name == 'push' }} run: | RELEASE_TAG=mozjs-sys-v$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "mozjs_sys") | .version') + git fetch --tags --quiet + if ! git show-ref --tags --verify --quiet "refs/tags/${RELEASE_TAG}" ; then + gh release create ${{ steps.check-tag.outputs.RELEASE_TAG }} ./*.tar.gz + fi echo "RELEASE_TAG=${RELEASE_TAG}" >> ${GITHUB_OUTPUT} - - name: Publish release - if: ${{ steps.check-tag.outputs.RELEASE_TAG != '' }} - run: gh release create ${{ steps.check-tag.outputs.RELEASE_TAG }} ./*.tar.gz || exit 0 outputs: release-tag: ${{ steps.check-tag.outputs.RELEASE_TAG }} From 3809e36ea8a1ae59f4926a6c969047be9f716a2c Mon Sep 17 00:00:00 2001 From: Wu Yu Wei Date: Sat, 9 Mar 2024 17:31:59 +0900 Subject: [PATCH 21/21] Fix tag variable --- .github/workflows/rust.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index a57f8ba87ef..c6d6c335176 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -207,7 +207,7 @@ jobs: RELEASE_TAG=mozjs-sys-v$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[] | select(.name == "mozjs_sys") | .version') git fetch --tags --quiet if ! git show-ref --tags --verify --quiet "refs/tags/${RELEASE_TAG}" ; then - gh release create ${{ steps.check-tag.outputs.RELEASE_TAG }} ./*.tar.gz + gh release create ${RELEASE_TAG} ./*.tar.gz fi echo "RELEASE_TAG=${RELEASE_TAG}" >> ${GITHUB_OUTPUT} outputs: