diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8b8857c8..72c11966 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,10 +3,10 @@ name: Release on: push: branches: - - test + - test release: types: - - 'published' + - 'published' jobs: build: @@ -16,141 +16,170 @@ jobs: fail-fast: false matrix: job: - # https://doc.rust-lang.org/nightly/rustc/platform-support.html - - { target: aarch64-apple-darwin , os: macos-13 } - - { target: aarch64-pc-windows-msvc , os: windows-2022 } - - { target: aarch64-linux-android , os: ubuntu-22.04, use-cross: true } - - { target: aarch64-unknown-linux-gnu , os: ubuntu-22.04, use-cross: true } - - { target: aarch64-unknown-linux-musl , os: ubuntu-22.04, use-cross: true } - - { target: arm-unknown-linux-gnueabihf , os: ubuntu-22.04, use-cross: true } - - { target: arm-unknown-linux-musleabihf, os: ubuntu-22.04, use-cross: true } - - { target: i686-pc-windows-msvc , os: windows-2022 } - - { target: i686-unknown-linux-gnu , os: ubuntu-22.04, use-cross: true } - - { target: i686-unknown-linux-musl , os: ubuntu-22.04, use-cross: true } - - { target: x86_64-apple-darwin , os: macos-13 } - - { target: x86_64-pc-windows-gnu , os: windows-2022 } - - { target: x86_64-pc-windows-msvc , os: windows-2022 } - - { target: x86_64-unknown-linux-gnu , os: ubuntu-22.04, use-cross: true } - - { target: x86_64-unknown-linux-musl , os: ubuntu-22.04, use-cross: true } + # https://doc.rust-lang.org/nightly/rustc/platform-support.html + - { target: aarch64-apple-darwin , os: macos-13 } + - { target: aarch64-pc-windows-msvc , os: windows-2022 } + - { target: aarch64-linux-android , os: ubuntu-22.04, use-cross: true } + - { target: aarch64-unknown-linux-gnu , os: ubuntu-22.04, use-cross: true } + - { target: aarch64-unknown-linux-musl , os: ubuntu-22.04, use-cross: true } + - { target: arm-unknown-linux-gnueabihf , os: ubuntu-22.04, use-cross: true } + - { target: arm-unknown-linux-musleabihf, os: ubuntu-22.04, use-cross: true } + - { target: i686-pc-windows-msvc , os: windows-2022 } + - { target: i686-unknown-linux-gnu , os: ubuntu-22.04, use-cross: true } + - { target: i686-unknown-linux-musl , os: ubuntu-22.04, use-cross: true } + - { target: x86_64-apple-darwin , os: macos-13 } + - { target: x86_64-pc-windows-gnu , os: windows-2022 } + - { target: x86_64-pc-windows-msvc , os: windows-2022 } + - { target: x86_64-unknown-linux-gnu , os: ubuntu-22.04, use-cross: true } + - { target: x86_64-unknown-linux-musl , os: ubuntu-22.04, use-cross: true } env: VERSION: $GITHUB_REF_NAME BUILD_CMD: cargo EXE_SUFFIX: "" PKG_LIVE777_NAME: "" + PKG_LIVEMAN_NAME: "" PKG_WHEPFROM_NAME: "" PKG_WHIPINTO_NAME: "" steps: - - name: Checkout source code - uses: actions/checkout@v4 - - - uses: actions/setup-node@v4 - with: - node-version: 22 - - - name: Install - run: npm install - - - name: Build Webui - run: npm run build - - - name: Get the release version from the tag - run: | - echo "version is: ${{ env.VERSION }}" - - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@stable - with: - targets: ${{ matrix.job.target }} - - - name: Install cross - if: matrix.job.use-cross - run: cargo install cross --git https://github.com/cross-rs/cross - - - name: Overwrite build command env variable - if: matrix.job.use-cross - shell: bash - run: echo "BUILD_CMD=cross" >> $GITHUB_ENV - - - name: Overwrite suffix env variable - if: runner.os == 'Windows' - shell: bash - run: echo "EXE_SUFFIX=.exe" >> $GITHUB_ENV - - - name: Show version information (Rust, cargo, GCC) - shell: bash - run: | - gcc --version || true - cross --version || true - rustup -V - rustup toolchain list - rustup default - cargo -V - rustc -V - echo "BUILD_CMD: ${BUILD_CMD}" - - - name: Build - shell: bash - run: | - $BUILD_CMD $BUILD_NDK build --locked --all --release --target=${{ matrix.job.target }} - - - name: Archive - shell: bash - run: | - PKG_BUILDNAME=${{ env.VERSION }}-${{ matrix.job.target }}${{ env.EXE_SUFFIX }} - echo "BUILD_PATH=target/${{ matrix.job.target }}/release" >> $GITHUB_ENV - echo "PKG_LIVE777_NAME=live777-${PKG_BUILDNAME}" >> $GITHUB_ENV - echo "PKG_WHEPFROM_NAME=whepfrom-${PKG_BUILDNAME}" >> $GITHUB_ENV - echo "PKG_WHIPINTO_NAME=whipinto-${PKG_BUILDNAME}" >> $GITHUB_ENV - - - name: Create tarball - shell: bash - run: | - TAR_SUFFIX=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) TAR_SUFFIX=".zip" ;; esac; - TAR_BASENAME=live777-${{ env.VERSION }}-${{ matrix.job.target }} - TAR_NAME=${TAR_BASENAME}${TAR_SUFFIX} - ARCHIVE_DIR="${TAR_BASENAME}/" - - mkdir -p "${ARCHIVE_DIR}" - cp "${{ env.BUILD_PATH }}/live777${{ env.EXE_SUFFIX }}" "$ARCHIVE_DIR" - cp "README.md" "LICENSE" "conf/live777.toml" "conf/live777.service" "$ARCHIVE_DIR" - - # base compressed package - case ${{ matrix.job.target }} in + - name: Checkout source code + uses: actions/checkout@v4 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + + - name: Install + run: npm install + + - name: Build Webui + run: npm run build + + - name: Get the release version from the tag + run: | + echo "version is: ${{ env.VERSION }}" + + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@stable + with: + targets: ${{ matrix.job.target }} + + - name: Install cross + if: matrix.job.use-cross + run: cargo install cross --git https://github.com/cross-rs/cross + + - name: Overwrite build command env variable + if: matrix.job.use-cross + shell: bash + run: echo "BUILD_CMD=cross" >> $GITHUB_ENV + + - name: Overwrite suffix env variable + if: runner.os == 'Windows' + shell: bash + run: echo "EXE_SUFFIX=.exe" >> $GITHUB_ENV + + - name: Show version information (Rust, cargo, GCC) + shell: bash + run: | + gcc --version || true + cross --version || true + rustup -V + rustup toolchain list + rustup default + cargo -V + rustc -V + echo "BUILD_CMD: ${BUILD_CMD}" + + - name: Build + shell: bash + run: | + $BUILD_CMD $BUILD_NDK build --locked --all --release --target=${{ matrix.job.target }} + + - name: Archive + shell: bash + run: | + PKG_BUILDNAME=${{ env.VERSION }}-${{ matrix.job.target }}${{ env.EXE_SUFFIX }} + echo "BUILD_PATH=target/${{ matrix.job.target }}/release" >> $GITHUB_ENV + echo "PKG_LIVE777_NAME=live777-${PKG_BUILDNAME}" >> $GITHUB_ENV + echo "PKG_LIVEMAN_NAME=liveman-${PKG_BUILDNAME}" >> $GITHUB_ENV + echo "PKG_WHEPFROM_NAME=whepfrom-${PKG_BUILDNAME}" >> $GITHUB_ENV + echo "PKG_WHIPINTO_NAME=whipinto-${PKG_BUILDNAME}" >> $GITHUB_ENV + + - name: Create Live777 tarball + shell: bash + run: | + TAR_SUFFIX=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) TAR_SUFFIX=".zip" ;; esac; + TAR_BASENAME=live777-${{ env.VERSION }}-${{ matrix.job.target }} + TAR_NAME=${TAR_BASENAME}${TAR_SUFFIX} + ARCHIVE_DIR="${TAR_BASENAME}/" + + mkdir -p "${ARCHIVE_DIR}" + cp "${{ env.BUILD_PATH }}/live777${{ env.EXE_SUFFIX }}" "$ARCHIVE_DIR" + cp "README.md" "LICENSE" "conf/live777.toml" "conf/live777.service" "$ARCHIVE_DIR" + + # base compressed package + case ${{ matrix.job.target }} in *-pc-windows-*) 7z -y a "${TAR_NAME}" "${TAR_BASENAME}"/* | tail -2 ;; *) tar czf "${TAR_NAME}" "${TAR_BASENAME}"/* ;; - esac; - - # Let subsequent steps know where to find the compressed package - echo "TAR_LIVE777_NAME=${TAR_NAME}" >> $GITHUB_ENV - - - name: Artifact Upload - uses: actions/upload-artifact@v4 - with: - name: ${{ env.TAR_LIVE777_NAME }} - path: ${{ env.TAR_LIVE777_NAME }} - - - name: Artifact Upload Whepfrom - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PKG_WHEPFROM_NAME }} - path: ${{ env.BUILD_PATH }}/whepfrom${{ env.EXE_SUFFIX }} - - - name: Artifact Upload Whipinto - uses: actions/upload-artifact@v4 - with: - name: ${{ env.PKG_WHIPINTO_NAME }} - path: ${{ env.BUILD_PATH }}/whipinto${{ env.EXE_SUFFIX }} - - - name: Rename binary - shell: bash - run: | - mv ${{ env.BUILD_PATH }}/whepfrom${{ env.EXE_SUFFIX }} ${{ env.PKG_WHEPFROM_NAME }} - mv ${{ env.BUILD_PATH }}/whipinto${{ env.EXE_SUFFIX }} ${{ env.PKG_WHIPINTO_NAME }} - - - name: Upload release archive - shell: bash - if: github.ref_type == 'tag' - run: gh release upload ${{ env.VERSION }} ${{ env.TAR_LIVE777_NAME }} ${{ env.PKG_WHEPFROM_NAME }} ${{ env.PKG_WHIPINTO_NAME }} - env: - GH_TOKEN: ${{ github.token }} + esac; + + # Let subsequent steps know where to find the compressed package + echo "TAR_LIVE777_NAME=${TAR_NAME}" >> $GITHUB_ENV + + - name: Create LiveMan tarball + shell: bash + run: | + TAR_SUFFIX=".tar.gz" ; case ${{ matrix.job.target }} in *-pc-windows-*) TAR_SUFFIX=".zip" ;; esac; + TAR_BASENAME=liveman-${{ env.VERSION }}-${{ matrix.job.target }} + TAR_NAME=${TAR_BASENAME}${TAR_SUFFIX} + ARCHIVE_DIR="${TAR_BASENAME}/" + + mkdir -p "${ARCHIVE_DIR}" + cp "${{ env.BUILD_PATH }}/liveman${{ env.EXE_SUFFIX }}" "$ARCHIVE_DIR" + cp "README.md" "LICENSE" "conf/liveman.toml" "conf/liveman.service" "$ARCHIVE_DIR" + + # base compressed package + case ${{ matrix.job.target }} in + *-pc-windows-*) 7z -y a "${TAR_NAME}" "${TAR_BASENAME}"/* | tail -2 ;; + *) tar czf "${TAR_NAME}" "${TAR_BASENAME}"/* ;; + esac; + + # Let subsequent steps know where to find the compressed package + echo "TAR_LIVEMAN_NAME=${TAR_NAME}" >> $GITHUB_ENV + + - name: Artifact Upload Live777 + uses: actions/upload-artifact@v4 + with: + name: ${{ env.TAR_LIVE777_NAME }} + path: ${{ env.TAR_LIVE777_NAME }} + + - name: Artifact Upload LiveMan + uses: actions/upload-artifact@v4 + with: + name: ${{ env.TAR_LIVEMAN_NAME }} + path: ${{ env.TAR_LIVEMAN_NAME }} + + - name: Artifact Upload Whepfrom + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PKG_WHEPFROM_NAME }} + path: ${{ env.BUILD_PATH }}/whepfrom${{ env.EXE_SUFFIX }} + + - name: Artifact Upload Whipinto + uses: actions/upload-artifact@v4 + with: + name: ${{ env.PKG_WHIPINTO_NAME }} + path: ${{ env.BUILD_PATH }}/whipinto${{ env.EXE_SUFFIX }} + + - name: Rename binary + shell: bash + run: | + mv ${{ env.BUILD_PATH }}/whepfrom${{ env.EXE_SUFFIX }} ${{ env.PKG_WHEPFROM_NAME }} + mv ${{ env.BUILD_PATH }}/whipinto${{ env.EXE_SUFFIX }} ${{ env.PKG_WHIPINTO_NAME }} + + - name: Upload release archive + shell: bash + if: github.ref_type == 'tag' + run: gh release upload ${{ env.VERSION }} ${{ env.TAR_LIVE777_NAME }} ${{ env.TAR_LIVEMAN_NAME }} ${{ env.PKG_WHEPFROM_NAME }} ${{ env.PKG_WHIPINTO_NAME }} + env: + GH_TOKEN: ${{ github.token }}