Skip to content

Commit

Permalink
github: 复用 release
Browse files Browse the repository at this point in the history
  • Loading branch information
xychen committed Jun 17, 2022
1 parent ba482a5 commit 96b64d8
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 41 deletions.
34 changes: 34 additions & 0 deletions .github/actions/release-tar-xz/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
37 changes: 37 additions & 0 deletions .github/actions/release-zip/action.yml
Original file line number Diff line number Diff line change
@@ -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 }}
72 changes: 31 additions & 41 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down Expand Up @@ -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 }}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 }}

0 comments on commit 96b64d8

Please sign in to comment.