Skip to content

Commit

Permalink
支持选择是否发布Release
Browse files Browse the repository at this point in the history
  • Loading branch information
nilaoda committed Apr 5, 2023
1 parent 0145728 commit 631bebd
Showing 1 changed file with 45 additions and 41 deletions.
86 changes: 45 additions & 41 deletions .github/workflows/build_latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@ name: Build Latest
on:
workflow_dispatch:
inputs:
doRelease:
description: 'Publish new release'
type: boolean
default: false
required: false
tag:
type: string
description: 'Release version tag (e.g. v1.2.3)'
Expand All @@ -17,45 +22,8 @@ env:
DOTNET_SDK_VERSION: "7.0.*"

jobs:
create_draft_release:
name: Create Github draft release
runs-on: ubuntu-latest
steps:
- name: Audit gh version
run: gh --version

- name: Check for existing release
id: check_release
run: |
echo "::echo::on"
gh release view --repo '${{ github.repository }}' '${{ github.event.inputs.tag }}' \
&& echo "already_exists=true" >> $GITHUB_ENV \
|| echo "already_exists=false" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout repo
if: env.already_exists == 'false'
uses: actions/checkout@v3
with:
ref: '${{ github.event.inputs.ref }}'

- name: Create release
if: env.already_exists == 'false'
run: >
gh release create
'${{ github.event.inputs.tag }}'
--draft
--repo '${{ github.repository }}'
--title '${{ github.event.inputs.tag }}'
--target '${{ github.event.inputs.ref }}'
--generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

build-win-x64-arm64:
runs-on: windows-latest
needs: create_draft_release

steps:
- uses: actions/checkout@v2
Expand Down Expand Up @@ -84,7 +52,6 @@ jobs:
build-linux-x64:
runs-on: ubuntu-latest
container: ubuntu:18.04
needs: create_draft_release

steps:
- run: apt-get update
Expand All @@ -107,7 +74,6 @@ jobs:
build-linux-arm64:
runs-on: ubuntu-latest
container: mcr.microsoft.com/dotnet-buildtools/prereqs:ubuntu-18.04-cross-arm64-20220312201346-b2c2436
needs: create_draft_release

steps:
- uses: actions/checkout@v2
Expand All @@ -126,7 +92,6 @@ jobs:

build-mac-x64-arm64:
runs-on: macos-latest
needs: create_draft_release

steps:
- uses: actions/checkout@v2
Expand All @@ -153,9 +118,48 @@ jobs:
name: N_m3u8DL-RE_Beta_osx-arm64
path: artifact-arm64/N_m3u8DL-RE

create_draft_release:
name: Create Github draft release
if: ${{ github.event.inputs.doRelease == 'true' }}
needs: [build-win-x64-arm64,build-linux-x64,build-linux-arm64,build-mac-x64-arm64]
runs-on: ubuntu-latest
steps:
- name: Audit gh version
run: gh --version

- name: Check for existing release
id: check_release
run: |
echo "::echo::on"
gh release view --repo '${{ github.repository }}' '${{ github.event.inputs.tag }}' \
&& echo "already_exists=true" >> $GITHUB_ENV \
|| echo "already_exists=false" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout repo
if: env.already_exists == 'false'
uses: actions/checkout@v3
with:
ref: '${{ github.event.inputs.ref }}'

- name: Create release
if: env.already_exists == 'false'
run: >
gh release create
'${{ github.event.inputs.tag }}'
--draft
--repo '${{ github.repository }}'
--title '${{ github.event.inputs.tag }}'
--target '${{ github.event.inputs.ref }}'
--generate-notes
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

attach_to_release:
name: Attach native executables to release
needs: [build-win-x64-arm64,build-linux-x64,build-linux-arm64,build-mac-x64-arm64]
if: ${{ github.event.inputs.doRelease == 'true' }}
needs: create_draft_release
runs-on: ubuntu-latest
steps:
- name: Get current date
Expand Down

0 comments on commit 631bebd

Please sign in to comment.