From 135a6fb877c0b30609843428828d30195bb948b2 Mon Sep 17 00:00:00 2001 From: Integral Date: Fri, 28 Jun 2024 12:08:16 +0800 Subject: [PATCH] chore: update workflow from template repo --- .github/build-for-linux/Dockerfile | 8 -- .github/build-for-linux/action.yml | 21 ---- .github/build-for-linux/build.sh | 8 -- .github/build-for-linux/entrypoint.sh | 48 -------- .github/workflows/build.yml | 161 +++----------------------- 5 files changed, 13 insertions(+), 233 deletions(-) delete mode 100644 .github/build-for-linux/Dockerfile delete mode 100644 .github/build-for-linux/action.yml delete mode 100644 .github/build-for-linux/build.sh delete mode 100644 .github/build-for-linux/entrypoint.sh diff --git a/.github/build-for-linux/Dockerfile b/.github/build-for-linux/Dockerfile deleted file mode 100644 index cc0213b..0000000 --- a/.github/build-for-linux/Dockerfile +++ /dev/null @@ -1,8 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Integral -# -# SPDX-License-Identifier: GPL-3.0-or-later - -FROM rust:buster -COPY entrypoint.sh /entrypoint.sh -RUN chmod a+x /entrypoint.sh -ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/.github/build-for-linux/action.yml b/.github/build-for-linux/action.yml deleted file mode 100644 index 89a1f42..0000000 --- a/.github/build-for-linux/action.yml +++ /dev/null @@ -1,21 +0,0 @@ -# SPDX-FileCopyrightText: 2024 Integral -# -# SPDX-License-Identifier: GPL-3.0-or-later - -name: 'Build for Linux' -branding: - icon: user-check - color: gray-dark -inputs: - target: - required: true - description: 'Rust Target' - toolchain: - required: true - description: 'Rust Toolchain' -runs: - using: 'docker' - image: 'Dockerfile' - args: - - ${{ inputs.target }} - - ${{ inputs.toolchain }} \ No newline at end of file diff --git a/.github/build-for-linux/build.sh b/.github/build-for-linux/build.sh deleted file mode 100644 index bbc329f..0000000 --- a/.github/build-for-linux/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -# SPDX-FileCopyrightText: 2024 Integral -# -# SPDX-License-Identifier: GPL-3.0-or-later - -cargo build --target "$INPUT_TARGET" --release -mv target/$INPUT_TARGET/release/libplugin.so ./plugin.so diff --git a/.github/build-for-linux/entrypoint.sh b/.github/build-for-linux/entrypoint.sh deleted file mode 100644 index edaf081..0000000 --- a/.github/build-for-linux/entrypoint.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash - -# SPDX-FileCopyrightText: 2024 Integral -# -# SPDX-License-Identifier: GPL-3.0-or-later - -rustup target add "$INPUT_TARGET" -rustup toolchain install --force-non-host "$INPUT_TOOLCHAIN" -apt-get install pkg-config - -if [ "$INPUT_TARGET" = "x86_64-unknown-linux-gnu" ]; then - apt-get update - apt-get install -y libssl-dev -elif [ "$INPUT_TARGET" = "i686-unknown-linux-gnu" ]; then - dpkg --add-architecture i386 - apt-get update - apt-get install -y libstdc++6:i386 libatomic1:i386 gcc-multilib g++-multilib libssl-dev:i386 - export PKG_CONFIG_PATH=/usr/lib/i386-linux-gnu/pkgconfig/:$PKG_CONFIG_PATH - export PKG_CONFIG_SYSROOT_DIR=/ -elif [ "$INPUT_TARGET" = "aarch64-unknown-linux-gnu" ]; then - sed 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch-=amd64,i386] http:\/\/ports.ubuntu.com\/ubuntu-ports\//g' /etc/apt/sources.list | tee /etc/apt/sources.list.d/ports.list - sed -i 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch=amd64,i386] http:\/\/\1.archive.ubuntu.com\/ubuntu\//g' /etc/apt/sources.list - dpkg --add-architecture arm64 - apt-get update - apt-get install -y libncurses6:arm64 libtinfo6:arm64 linux-libc-dev:arm64 libncursesw6:arm64 libcups2:arm64 - apt-get install -y --no-install-recommends g++-aarch64-linux-gnu libc6-dev-arm64-cross libssl-dev:arm64 - export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc - export CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc - export CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++ - export PKG_CONFIG_PATH=/usr/lib/aarch64-linux-gnu/pkgconfig - export PKG_CONFIG_ALLOW_CROSS=1 -elif [ "$INPUT_TARGET" = "armv7-unknown-linux-gnueabihf" ]; then - sed 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch-=amd64,i386] http:\/\/ports.ubuntu.com\/ubuntu-ports\//g' /etc/apt/sources.list | tee /etc/apt/sources.list.d/ports.list - sed -i 's/http:\/\/\(.*\).ubuntu.com\/ubuntu\//[arch=amd64,i386] http:\/\/\1.archive.ubuntu.com\/ubuntu\//g' /etc/apt/sources.list - dpkg --add-architecture armhf - apt-get update - apt-get install -y libncurses6:armhf libtinfo6:armhf linux-libc-dev:armhf libncursesw6:armhf libcups2:armhf - apt-get install -y --no-install-recommends g++-arm-linux-gnueabihf libc6-dev-armhf-cross libssl-dev:armhf libwebkit2gtk-4.0-dev:armhf libgtk-3-dev:armhf patchelf:armhf librsvg2-dev:armhf - export CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc - export CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc - export CXX_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-g++ - export PKG_CONFIG_PATH=/usr/lib/arm-linux-gnueabihf/pkgconfig - export PKG_CONFIG_ALLOW_CROSS=1 -else - echo "Unknown target: $INPUT_TARGET" && exit 1 -fi - -bash .github/build-for-linux/build.sh diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 9545999..6677d5c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,169 +1,34 @@ -# SPDX-FileCopyrightText: 2024 Integral -# -# SPDX-License-Identifier: GPL-3.0-or-later - name: Build on: push +permissions: write-all jobs: - check: + build: runs-on: ubuntu-latest - outputs: - name: ${{ steps.getname.outputs.NAME }} - icon: ${{ steps.getname.outputs.ICON }} steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 1 - - name: Install Rust Stable - uses: dtolnay/rust-toolchain@stable - - name: check - run: cargo check --all --all-targets - name: Install zip - run: sudo apt-get install -y zip jq + run: sudo apt-get install -y jq - id: getname run: | - echo "NAME=$(cat info.json | jq '.id' | tr -d '"')" >> "$GITHUB_OUTPUT" - echo "ICON=$(cat info.json | jq '.icon' | tr -d '"')" >> "$GITHUB_OUTPUT" - build-for-windows: - needs: check - strategy: - fail-fast: false - matrix: - platform: [windows-latest] - target: - [ - x86_64-pc-windows-msvc, - i686-pc-windows-msvc, - aarch64-pc-windows-msvc, - ] - runs-on: ${{ matrix.platform }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - name: Install Rust Stable - uses: dtolnay/rust-toolchain@stable - - name: install toolchain - run: | - rustup target add ${{ matrix.target }} - rustup toolchain install --force-non-host stable-${{ matrix.target }} - - name: Build - run: cargo build --release --target ${{ matrix.target }} - - name: Rename - run: move target/${{ matrix.target }}/release/plugin.dll ./plugin.dll - - uses: vimtor/action-zip@v1 - with: - files: info.json ${{needs.check.outputs.icon}} plugin.dll - dest: ${{needs.check.outputs.name}}.potext - - name: Upload Artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.target }} - path: "*.potext" - if-no-files-found: error - - name: Wrap - if: startsWith(github.ref, 'refs/tags') - uses: vimtor/action-zip@v1 - with: - files: ${{needs.check.outputs.name}}.potext - dest: ${{ matrix.target }}.zip - - name: Upload Release - if: startsWith(github.ref, 'refs/tags') - uses: softprops/action-gh-release@v1 - with: - token: ${{ secrets.TOKEN }} - files: ${{ matrix.target }}.zip - build-for-macos: - needs: check - strategy: - fail-fast: false - matrix: - platform: [macos-latest] - target: [x86_64-apple-darwin, aarch64-apple-darwin] - runs-on: ${{ matrix.platform }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - name: Install Rust Stable - uses: dtolnay/rust-toolchain@stable - - name: install toolchain - run: | - rustup target add ${{ matrix.target }} - rustup toolchain install --force-non-host stable-${{ matrix.target }} - - name: Build - run: cargo build --release --target ${{ matrix.target }} - - name: Rename - run: sudo mv target/${{ matrix.target }}/release/libplugin.dylib ./plugin.dylib - - uses: vimtor/action-zip@v1 - with: - files: info.json ${{needs.check.outputs.icon}} plugin.dylib - dest: ${{needs.check.outputs.name}}.potext - - name: Upload Artifacts - uses: actions/upload-artifact@v3 - with: - name: ${{ matrix.target }} - path: "*.potext" - if-no-files-found: error - - name: Wrap - if: startsWith(github.ref, 'refs/tags') - uses: vimtor/action-zip@v1 - with: - files: ${{needs.check.outputs.name}}.potext - dest: ${{ matrix.target }}.zip - - name: Upload Release - if: startsWith(github.ref, 'refs/tags') - uses: softprops/action-gh-release@v1 - with: - token: ${{ secrets.TOKEN }} - files: ${{ matrix.target }}.zip - build-for-linux: - needs: check - strategy: - fail-fast: false - matrix: - platform: [ubuntu-latest] - target: - [ - x86_64-unknown-linux-gnu, - i686-unknown-linux-gnu, - aarch64-unknown-linux-gnu, - armv7-unknown-linux-gnueabihf, - ] - runs-on: ${{ matrix.platform }} - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - fetch-depth: 1 - - name: Build for Linux - uses: ./.github/build-for-linux - with: - target: ${{ matrix.target }} - toolchain: stable-${{ matrix.target }} + echo "NAME=$(cat info.json | jq '.id' | tr -d '"')" >> "$GITHUB_ENV" + echo "ICON=$(cat info.json | jq '.icon' | tr -d '"')" >> "$GITHUB_ENV" - uses: vimtor/action-zip@v1 with: - files: info.json ${{needs.check.outputs.icon}} plugin.so - dest: ${{needs.check.outputs.name}}.potext + files: info.json ${{ env.ICON }} main.js + dest: ${{ env.NAME }}.potext - name: Upload Artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: ${{ matrix.target }} + name: ${{ env.NAME }}.potext path: "*.potext" if-no-files-found: error - - name: Wrap - if: startsWith(github.ref, 'refs/tags') - uses: vimtor/action-zip@v1 - with: - files: ${{needs.check.outputs.name}}.potext - dest: ${{ matrix.target }}.zip - name: Upload Release if: startsWith(github.ref, 'refs/tags') - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: - token: ${{ secrets.TOKEN }} - files: ${{ matrix.target }}.zip + token: ${{ secrets.GITHUB_TOKEN }} + files: "*.potext"