From 96b64d80176fc430291e8389a9f24dcb5a611feb Mon Sep 17 00:00:00 2001 From: xychen Date: Fri, 17 Jun 2022 13:17:59 +0800 Subject: [PATCH] =?UTF-8?q?github:=20=E5=A4=8D=E7=94=A8=20release?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/actions/release-tar-xz/action.yml | 34 +++++++++++ .github/actions/release-zip/action.yml | 37 ++++++++++++ .github/workflows/build.yml | 72 ++++++++++------------- 3 files changed, 102 insertions(+), 41 deletions(-) create mode 100644 .github/actions/release-tar-xz/action.yml create mode 100644 .github/actions/release-zip/action.yml diff --git a/.github/actions/release-tar-xz/action.yml b/.github/actions/release-tar-xz/action.yml new file mode 100644 index 0000000..0578666 --- /dev/null +++ b/.github/actions/release-tar-xz/action.yml @@ -0,0 +1,34 @@ +name: Release tar.xz + +inputs: + shell: + description: 'The shell to use' + required: false + default: bash + name: + description: 'The name of the release' + required: true + root-dir: + description: 'The root directory' + required: false + default: build + files: + description: 'The files to pack' + required: true + tag: + description: 'The tag to release' + required: true + token: + description: 'The GitHub token' + required: true + +runs: + using: composite + steps: + - run: tar -caf ${{ inputs.name }} -C ${{ inputs.root-dir }} ${{ inputs.files }} + shell: ${{ inputs.shell }} + - uses: svenstaro/upload-release-action@v2 + with: + file: ${{ inputs.name }} + tag: ${{ inputs.tag }} + repo_token: ${{ inputs.token }} diff --git a/.github/actions/release-zip/action.yml b/.github/actions/release-zip/action.yml new file mode 100644 index 0000000..e4cd275 --- /dev/null +++ b/.github/actions/release-zip/action.yml @@ -0,0 +1,37 @@ +name: Release zip + +inputs: + shell: + description: 'The shell to use' + required: false + default: bash + name: + description: 'The name of the release' + required: true + root-dir: + description: 'The root directory' + required: false + default: build + files: + description: 'The files to pack' + required: true + tag: + description: 'The tag to release' + required: true + token: + description: 'The GitHub token' + required: true + +runs: + using: composite + steps: + - run: | + REPO_DIR=$PWD + cd ${{ inputs.root-dir }} + zip -r9 $REPO_DIR/${{ inputs.name }} ${{ inputs.files }} + shell: ${{ inputs.shell }} + - uses: svenstaro/upload-release-action@v2 + with: + file: ${{ inputs.name }} + tag: ${{ inputs.tag }} + repo_token: ${{ inputs.token }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 4e84030..6d646a7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -37,17 +37,15 @@ jobs: path: build/cskburn/cskburn if-no-files-found: error - - name: Pack release assets + - name: Upload release if: ${{ startsWith(github.ref, 'refs/tags/v') }} - run: tar -caf cskburn-${{ matrix.name }}.tar.xz -C build/cskburn cskburn - - - name: Release - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - uses: svenstaro/upload-release-action@v2 + uses: ./.github/actions/release-tar-xz with: - file: cskburn-${{ matrix.name }}.tar.xz + name: cskburn-${{ matrix.name }}.tar.xz + root-dir: build/cskburn + files: cskburn tag: ${{ github.ref }} - repo_token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} build-silicon: runs-on: ${{ matrix.os }} @@ -78,17 +76,15 @@ jobs: path: build/cskburn/cskburn if-no-files-found: error - - name: Pack release assets - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - run: tar -caf cskburn-${{ matrix.name }}.tar.xz -C build/cskburn cskburn - - - name: Release + - name: Upload release if: ${{ startsWith(github.ref, 'refs/tags/v') }} - uses: svenstaro/upload-release-action@v2 + uses: ./.github/actions/release-tar-xz with: - file: cskburn-${{ matrix.name }}.tar.xz + name: cskburn-${{ matrix.name }}.tar.xz + root-dir: build/cskburn + files: cskburn tag: ${{ github.ref }} - repo_token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} build-win32: runs-on: ${{ matrix.os }} @@ -129,18 +125,16 @@ jobs: path: build/cskburn/cskburn.exe if-no-files-found: error - - name: Pack release assets - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - shell: msys2 {0} - run: zip -9 -j cskburn-${{ matrix.name }}.zip build/cskburn/cskburn.exe - - - name: Release + - name: Upload release if: ${{ startsWith(github.ref, 'refs/tags/v') }} - uses: svenstaro/upload-release-action@v2 + uses: ./.github/actions/release-zip with: - file: cskburn-${{ matrix.name }}.zip + shell: msys2 {0} + name: cskburn-${{ matrix.name }}.zip + root-dir: build/cskburn + files: cskburn.exe tag: ${{ github.ref }} - repo_token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} build-docker: runs-on: ubuntu-latest @@ -189,17 +183,15 @@ jobs: path: build/cskburn/cskburn if-no-files-found: error - - name: Pack release assets - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - run: tar -caf cskburn-${{ matrix.name }}.tar.xz -C build/cskburn cskburn - - - name: Release + - name: Upload release if: ${{ startsWith(github.ref, 'refs/tags/v') }} - uses: svenstaro/upload-release-action@v2 + uses: ./.github/actions/release-tar-xz with: - file: cskburn-${{ matrix.name }}.tar.xz + name: cskburn-${{ matrix.name }}.tar.xz + root-dir: build/cskburn + files: cskburn tag: ${{ github.ref }} - repo_token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }} build-android: runs-on: ubuntu-latest @@ -233,14 +225,12 @@ jobs: path: build/cskburn/cskburn if-no-files-found: error - - name: Pack release assets - if: ${{ startsWith(github.ref, 'refs/tags/v') }} - run: tar -caf cskburn-${{ matrix.name }}.tar.xz -C build/cskburn cskburn - - - name: Release + - name: Upload release if: ${{ startsWith(github.ref, 'refs/tags/v') }} - uses: svenstaro/upload-release-action@v2 + uses: ./.github/actions/release-tar-xz with: - file: cskburn-${{ matrix.name }}.tar.xz + name: cskburn-${{ matrix.name }}.tar.xz + root-dir: build/cskburn + files: cskburn tag: ${{ github.ref }} - repo_token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.GITHUB_TOKEN }}