Skip to content

Commit

Permalink
Use boolean inputs & run custom command
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongfly committed Feb 13, 2022
1 parent e29023a commit ce17b75
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
26 changes: 17 additions & 9 deletions .github/workflows/mpv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,25 @@ on:
# - cron: '0 12 * * *'
workflow_dispatch:
inputs:
clean:
description: 'input anything if you want to clean build files'
needclean:
description: 'Delete cache and completely rebuild erverything'
required: true
default: false
type: boolean
release:
description: "Publish a release"
required: true
default: false
type: boolean
command:
description: 'input command you want to run before build'
required: false
cache_id:
description: 'input cache_id if you want to renew cache'
required: false
release:
description: "input 'false' if you don't want to release"
required: false
default: "true"

env:
release: false

jobs:
build_mpv:
name: Build MPV
Expand Down Expand Up @@ -57,7 +65,7 @@ jobs:
id: build
shell: bash
run: |
docker run --rm -v $GITHUB_WORKSPACE:/root/workdir archlinux:base-devel /usr/bin/bash -c "cd /root/workdir && chmod +x build.sh && bash build.sh '${{ matrix.bit }}' '${{ github.event.inputs.clean }}'"
docker run --rm -v $GITHUB_WORKSPACE:/root/workdir archlinux:base-devel /usr/bin/bash -c "cd /root/workdir && chmod +x build.sh && bash build.sh '${{ matrix.bit }}' '${{ github.event.inputs.needclean }}' '${{ github.event.inputs.command }}'"
- name: Collect error logs
if: ${{ always() && steps.build.outcome == 'failure' }}
run: |
Expand All @@ -78,7 +86,7 @@ jobs:
publish_release:
name: Publish release
needs: build_mpv
if: ${{ github.event.inputs.release != 'false' }}
if: ${{ (github.event.inputs.release != null && github.event.inputs.release == 'true') || (github.event.inputs.release == null && env.release == 'true') }}
runs-on: ubuntu-latest

steps:
Expand Down
10 changes: 7 additions & 3 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ main() {
git checkout $branch
gitdir=$(pwd)
buildroot=$(pwd)
isClean=$2
needClean="$2"
userCommand="$3"

prepare
if [ "$1" == "32" ]; then
Expand All @@ -44,10 +45,13 @@ package() {
local bit=$1
local arch=$2

if [ -n "$isClean" ]; then
if [ "$needClean" == "true" ]; then
echo "Clean $bit-bit build files"
sudo rm -rf $buildroot/build$bit
fi
if [ -n "$userCommand" ]; then
eval "$userCommand"
fi
build $bit $arch
zip $bit $arch
sudo rm -rf $buildroot/build$bit/mpv-$arch*
Expand Down Expand Up @@ -117,4 +121,4 @@ prepare() {
cd ../..
}

main $1 $2
main "$1" "$2" "$3"

0 comments on commit ce17b75

Please sign in to comment.