From f6602beaf849e57c984e1e1c7c08110fdd328025 Mon Sep 17 00:00:00 2001 From: EAimTY Date: Tue, 23 May 2023 17:14:53 +0900 Subject: [PATCH] action workflows for building and releasing --- .github/workflows/binary-release.yml | 168 ++++++++++++++++++++++ .github/workflows/library-release.yml | 43 ++++++ .github/workflows/release-tuic-client.yml | 13 ++ .github/workflows/release-tuic-quinn.yml | 13 ++ .github/workflows/release-tuic-server.yml | 13 ++ .github/workflows/release-tuic.yml | 13 ++ Cargo.toml | 6 + 7 files changed, 269 insertions(+) create mode 100644 .github/workflows/binary-release.yml create mode 100644 .github/workflows/library-release.yml create mode 100644 .github/workflows/release-tuic-client.yml create mode 100644 .github/workflows/release-tuic-quinn.yml create mode 100644 .github/workflows/release-tuic-server.yml create mode 100644 .github/workflows/release-tuic.yml diff --git a/.github/workflows/binary-release.yml b/.github/workflows/binary-release.yml new file mode 100644 index 0000000..fd45b0d --- /dev/null +++ b/.github/workflows/binary-release.yml @@ -0,0 +1,168 @@ +name: binary-release + +on: + workflow_call: + inputs: + PACKAGE_NAME: + required: true + type: string + +jobs: + binary-release: + permissions: + contents: write + + strategy: + fail-fast: false + matrix: + include: + - arch-name: x86_64-unknown-linux-gnu + os: ubuntu-latest + target: x86_64-unknown-linux-gnu + cross: false + file-ext: + + - arch-name: x86_64-unknown-linux-musl + os: ubuntu-latest + target: x86_64-unknown-linux-musl + cross: true + file-ext: + + - arch-name: x86_64-unknown-freebsd + os: ubuntu-latest + target: x86_64-unknown-freebsd + cross: true + file-ext: + + - arch-name: x86_64-pc-windows-msvc + os: windows-latest + target: x86_64-pc-windows-msvc + cross: false + file-ext: .exe + + - arch-name: x86_64-pc-windows-gnu + os: ubuntu-latest + target: x86_64-pc-windows-gnu + cross: true + file-ext: .exe + + - arch-name: x86_64-apple-darwin + os: macos-latest + target: x86_64-apple-darwin + cross: false + file-ext: + + - arch-name: i686-unknown-linux-gnu + os: ubuntu-latest + target: i686-unknown-linux-gnu + cross: true + file-ext: + + - arch-name: i686-unknown-linux-musl + os: ubuntu-latest + target: i686-unknown-linux-musl + cross: true + file-ext: + + - arch-name: i686-pc-windows-msvc + os: windows-latest + target: i686-pc-windows-msvc + cross: true + file-ext: .exe + + - arch-name: aarch64-unknown-linux-gnu + os: ubuntu-latest + target: aarch64-unknown-linux-gnu + cross: true + file-ext: + + - arch-name: aarch64-unknown-linux-musl + os: ubuntu-latest + target: aarch64-unknown-linux-musl + cross: true + file-ext: + + - arch-name: aarch64-apple-darwin + os: macos-latest + target: aarch64-apple-darwin + cross: true + file-ext: + + - arch-name: armv7-unknown-linux-gnueabi + os: ubuntu-latest + target: armv7-unknown-linux-gnueabi + cross: true + file-ext: + + - arch-name: armv7-unknown-linux-gnueabihf + os: ubuntu-latest + target: armv7-unknown-linux-gnueabihf + cross: true + file-ext: + + - arch-name: armv7-unknown-linux-musleabi + os: ubuntu-latest + target: armv7-unknown-linux-musleabi + cross: true + file-ext: + + - arch-name: armv7-unknown-linux-musleabihf + os: ubuntu-latest + target: armv7-unknown-linux-musleabihf + cross: true + file-ext: + + runs-on: ${{ matrix.os }} + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + toolchain: nightly + target: ${{ matrix.target }} + override: true + + - name: Get package version on Unix-like system + if: runner.os != 'Windows' + run: | + echo "version=$(sed -rn 's/^version = \"(.*)\"/\1/p' ${{ inputs.PACKAGE_NAME }}/Cargo.toml)" >> $GITHUB_ENV + echo "prerelease=$((sed -rn 's/^version = \"(.*)\"/\1/p' ${{ inputs.PACKAGE_NAME }}/Cargo.toml | grep -qF '-') && echo "true" || echo "false")" >> $GITHUB_ENV + + - name: Get package version on Windows + if: runner.os == 'Windows' + run: | + chcp 65001 + echo "version=$(sed -rn 's/^version = \"(.*)\"/\1/p' ${{ inputs.PACKAGE_NAME }}/Cargo.toml)" >> $env:GITHUB_ENV + echo "prerelease=$((sed -rn 's/^version = \"(.*)\"/\1/p' ${{ inputs.PACKAGE_NAME }}/Cargo.toml | grep -qF '-') && echo "true" || echo "false")" >> $env:GITHUB_ENV + + - name: Build + uses: actions-rs/cargo@v1 + with: + use-cross: ${{ matrix.cross }} + command: build + args: --release -p ${{ inputs.PACKAGE_NAME }} --target ${{ matrix.target }} + + - name: Move binaries + run: | + mkdir artifacts/ + mv target/${{ matrix.target }}/release/${{ inputs.PACKAGE_NAME }}${{ matrix.file-ext }} artifacts/${{ inputs.PACKAGE_NAME }}-${{ env.version }}-${{ matrix.arch-name }}${{ matrix.file-ext }} + + - name: Calculate SHA256 + run: | + cd artifacts/ + openssl dgst -sha256 -r ${{ inputs.PACKAGE_NAME }}-${{ env.version }}-${{ matrix.arch-name }}${{ matrix.file-ext }} > ${{ inputs.PACKAGE_NAME }}-${{ env.version }}-${{ matrix.arch-name }}${{ matrix.file-ext }}.sha256sum + + - name: Release binaries + uses: ncipollo/release-action@v1 + with: + artifacts: "artifacts/*" + name: ${{ inputs.PACKAGE_NAME }}-${{ env.version }} + tag: ${{ inputs.PACKAGE_NAME }}-${{ env.version }} + commit: ${{ github.sha }} + allowUpdates: true + prerelease: ${{ env.prerelease }} diff --git a/.github/workflows/library-release.yml b/.github/workflows/library-release.yml new file mode 100644 index 0000000..07dc4f2 --- /dev/null +++ b/.github/workflows/library-release.yml @@ -0,0 +1,43 @@ +name: library-release + +on: + workflow_call: + inputs: + PACKAGE_NAME: + required: true + type: string + +jobs: + library-release: + permissions: + contents: write + + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Get package version on Unix-like system + if: runner.os != 'Windows' + run: | + echo "version=$(sed -rn 's/^version = \"(.*)\"/\1/p' ${{ inputs.PACKAGE_NAME }}/Cargo.toml)" >> $GITHUB_ENV + echo "prerelease=$((sed -rn 's/^version = \"(.*)\"/\1/p' ${{ inputs.PACKAGE_NAME }}/Cargo.toml | grep -qF '-') && echo "true" || echo "false")" >> $GITHUB_ENV + + - name: Get package version on Windows + if: runner.os == 'Windows' + run: | + chcp 65001 + echo "version=$(sed -rn 's/^version = \"(.*)\"/\1/p' ${{ inputs.PACKAGE_NAME }}/Cargo.toml)" >> $env:GITHUB_ENV + echo "prerelease=$((sed -rn 's/^version = \"(.*)\"/\1/p' ${{ inputs.PACKAGE_NAME }}/Cargo.toml | grep -qF '-') && echo "true" || echo "false")" >> $env:GITHUB_ENV + + - name: Release library + uses: ncipollo/release-action@v1 + with: + name: ${{ inputs.PACKAGE_NAME }}-${{ env.version }} + tag: ${{ inputs.PACKAGE_NAME }}-${{ env.version }} + commit: ${{ github.sha }} + allowUpdates: true + prerelease: ${{ env.prerelease }} diff --git a/.github/workflows/release-tuic-client.yml b/.github/workflows/release-tuic-client.yml new file mode 100644 index 0000000..57c6ddc --- /dev/null +++ b/.github/workflows/release-tuic-client.yml @@ -0,0 +1,13 @@ +name: release-tuic-client + +on: + workflow_dispatch: + +jobs: + release-tuic-client: + permissions: + contents: write + + uses: ./.github/workflows/binary-release.yml + with: + PACKAGE_NAME: "tuic-client" diff --git a/.github/workflows/release-tuic-quinn.yml b/.github/workflows/release-tuic-quinn.yml new file mode 100644 index 0000000..5cf9cca --- /dev/null +++ b/.github/workflows/release-tuic-quinn.yml @@ -0,0 +1,13 @@ +name: release-tuic-quinn + +on: + workflow_dispatch: + +jobs: + release-tuic-quinn: + permissions: + contents: write + + uses: ./.github/workflows/library-release.yml + with: + PACKAGE_NAME: "tuic-quinn" diff --git a/.github/workflows/release-tuic-server.yml b/.github/workflows/release-tuic-server.yml new file mode 100644 index 0000000..d7af332 --- /dev/null +++ b/.github/workflows/release-tuic-server.yml @@ -0,0 +1,13 @@ +name: release-tuic-server + +on: + workflow_dispatch: + +jobs: + release-tuic-server: + permissions: + contents: write + + uses: ./.github/workflows/binary-release.yml + with: + PACKAGE_NAME: "tuic-server" diff --git a/.github/workflows/release-tuic.yml b/.github/workflows/release-tuic.yml new file mode 100644 index 0000000..d66d6cb --- /dev/null +++ b/.github/workflows/release-tuic.yml @@ -0,0 +1,13 @@ +name: release-tuic + +on: + workflow_dispatch: + +jobs: + release-tuic: + permissions: + contents: write + + uses: ./.github/workflows/library-release.yml + with: + PACKAGE_NAME: "tuic" diff --git a/Cargo.toml b/Cargo.toml index cede657..350c9ac 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,2 +1,8 @@ [workspace] members = ["tuic", "tuic-quinn", "tuic-server", "tuic-client"] + +[profile.release] +lto = true +strip = true +codegen-units = 1 +panic = "abort"