Skip to content

Commit 49996d1

Browse files
committed
update script&workflow
1 parent f4e1326 commit 49996d1

File tree

4 files changed

+108
-62
lines changed

4 files changed

+108
-62
lines changed

.github/workflows/mpv.yml

+48-23
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,20 @@
11
name: MPV
22

33
on:
4-
workflow_dispatch:
54
# schedule:
65
# - cron: '0 8 * * */4'
6+
workflow_dispatch:
7+
inputs:
8+
clean:
9+
description: 'input anything if you want to clean build files'
10+
required: false
11+
cache_id:
12+
description: 'input cache_id if you want to renew cache'
13+
required: false
14+
release:
15+
description: "input 'false' if you don't want to release"
16+
required: false
17+
default: "true"
718

819
jobs:
920
build_mpv:
@@ -21,51 +32,65 @@ jobs:
2132
uses: mego22/actions-git-sha@main
2233
with:
2334
repo: "https://github.com/mpv-player/mpv.git"
24-
- name: 'Get winbuild latest commit sha'
25-
id: build_sha
26-
uses: mego22/actions-git-sha@main
27-
with:
28-
repo: "https://github.com/shinchiro/mpv-winbuild-cmake.git"
2935
- name: Get current time
3036
run: |
31-
echo "long_time=$(date "+%Y-%m-%d %H:%M")" >> $GITHUB_ENV
3237
echo "short_time=$(date "+%Y-%m-%d")" >> $GITHUB_ENV
3338
echo "month=$(date "+%Y-%m")" >> $GITHUB_ENV
34-
echo "sha=$(expr substr "${{ steps.get_sha.outputs.sha }}" 1 7)" >> $GITHUB_ENV
3539
3640
- name: Cache
3741
uses: actions/cache@v2
3842
with:
3943
path: mpv-winbuild-cmake/build${{ matrix.bit }}
40-
key: ${{ runner.os }}-mpv-build${{ matrix.bit }}-${{ env.month }}-${{ steps.build_sha.outputs.sha }}-${{ env.short_time }}
44+
key: ${{ runner.os }}-mpv-build${{ matrix.bit }}-${{ env.short_time }}-${{ steps.get_sha.outputs.sha }}-${{ github.event.inputs.cache_id }}
4145
restore-keys: |
42-
${{ runner.os }}-mpv-build${{ matrix.bit }}-${{ env.month }}-${{ steps.build_sha.outputs.sha }}
46+
${{ runner.os }}-mpv-build${{ matrix.bit }}-${{ env.short_time }}-${{ steps.get_sha.outputs.sha }}
47+
${{ runner.os }}-mpv-build${{ matrix.bit }}-${{ env.short_time }}
4348
${{ runner.os }}-mpv-build${{ matrix.bit }}-${{ env.month }}
44-
4549
- name: Build
4650
shell: bash
4751
run: |
48-
sudo bash build.sh "${{ matrix.bit }}"
49-
# - name: upload logs
50-
# uses: actions/upload-artifact@master
51-
# with:
52-
# name: logs
53-
# path: |
54-
# mpv-winbuild-cmake/build64/packages/mpv-prefix/src/mpv-stamp/mpv-build-*.log
55-
# mpv-winbuild-cmake/build64/packages/mujs-prefix/src/mujs-stamp/mujs-build-*.log
56-
# mpv-winbuild-cmake/build64/packages/libsrt-prefix/src/libsrt-stamp/libsrt-configure-*.log
52+
sudo bash build.sh "${{ matrix.bit }}" "${{ github.event.inputs.clean }}"
53+
# - name: upload logs
54+
# uses: actions/upload-artifact@master
55+
# if: always()
56+
# with:
57+
# name: logs
58+
# path: |
59+
# mpv-winbuild-cmake/build64/packages/mpv-prefix/src/mpv-stamp/mpv-*.log
5760

5861
- name: Upload artifact
5962
id: upload
6063
uses: kittaakos/upload-artifact-as-is@master
6164
with:
6265
path: mpv-winbuild-cmake/release/*.7z
6366

67+
publish_release:
68+
name: Publish release
69+
needs: build_mpv
70+
if: ${{ github.event.inputs.release }} != "false"
71+
runs-on: ubuntu-latest
72+
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v2
76+
- name: Download artifacts
77+
uses: actions/download-artifact@v2
78+
with:
79+
path: artifacts
80+
81+
- name: 'Get mpv latest commit sha'
82+
id: get_sha
83+
uses: mego22/actions-git-sha@main
84+
with:
85+
repo: "https://github.com/mpv-player/mpv.git"
86+
- name: Get current time
87+
run: |
88+
echo "long_time=$(date "+%Y-%m-%d %H:%M")" >> $GITHUB_ENV
89+
echo "short_time=$(date "+%Y-%m-%d")" >> $GITHUB_ENV
6490
- name: Create release
6591
uses: ncipollo/release-action@v1
66-
if: ${{ steps.upload.outcome == 'success' }}
6792
with:
68-
artifacts: "mpv-winbuild-cmake/release/*.7z"
93+
artifacts: "artifacts/*/*.7z"
6994
commit: main
7095
name: "MPV ${{ env.long_time }}"
7196
body: "MPV git commit: https://github.com/mpv-player/mpv/commit/${{ steps.get_sha.outputs.sha }}\nBuild Time: ${{ env.long_time }}"
@@ -78,4 +103,4 @@ jobs:
78103
run: |
79104
sudo bash prunetags.sh
80105
env:
81-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
106+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/mpv_own.yml

+48-23
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
11
name: MPV_OWN
22

33
on:
4-
workflow_dispatch:
54
schedule:
65
- cron: '0 8 * * */4'
6+
workflow_dispatch:
7+
inputs:
8+
clean:
9+
description: 'input anything if you want to clean build files'
10+
required: false
11+
cache_id:
12+
description: 'input cache_id if you want to renew cache'
13+
required: false
14+
release:
15+
description: "input 'false' if you don't want to release"
16+
required: false
17+
default: "true"
718

819
jobs:
920
build_mpv:
10-
name: Build MPV_OWN
21+
name: Build MPV
1122
runs-on: ubuntu-latest
1223
strategy:
1324
matrix:
@@ -21,51 +32,65 @@ jobs:
2132
uses: mego22/actions-git-sha@main
2233
with:
2334
repo: "https://github.com/mpv-player/mpv.git"
24-
- name: 'Get winbuild latest commit sha'
25-
id: build_sha
26-
uses: mego22/actions-git-sha@main
27-
with:
28-
repo: "https://github.com/dyphire/mpv-winbuild-cmake.git"
2935
- name: Get current time
3036
run: |
31-
echo "long_time=$(date "+%Y-%m-%d %H:%M")" >> $GITHUB_ENV
3237
echo "short_time=$(date "+%Y-%m-%d")" >> $GITHUB_ENV
3338
echo "month=$(date "+%Y-%m")" >> $GITHUB_ENV
34-
echo "sha=$(expr substr "${{ steps.get_sha.outputs.sha }}" 1 7)" >> $GITHUB_ENV
3539
3640
- name: Cache
3741
uses: actions/cache@v2
3842
with:
3943
path: mpv-winbuild-cmake/build${{ matrix.bit }}
40-
key: ${{ runner.os }}-mpv-build${{ matrix.bit }}-${{ env.month }}-${{ steps.build_sha.outputs.sha }}-${{ env.short_time }}
44+
key: ${{ runner.os }}-mpv-build${{ matrix.bit }}-${{ env.short_time }}-${{ steps.get_sha.outputs.sha }}-${{ github.event.inputs.cache_id }}
4145
restore-keys: |
42-
${{ runner.os }}-mpv-build${{ matrix.bit }}-${{ env.month }}-${{ steps.build_sha.outputs.sha }}
46+
${{ runner.os }}-mpv-build${{ matrix.bit }}-${{ env.short_time }}-${{ steps.get_sha.outputs.sha }}
47+
${{ runner.os }}-mpv-build${{ matrix.bit }}-${{ env.short_time }}
4348
${{ runner.os }}-mpv-build${{ matrix.bit }}-${{ env.month }}
44-
4549
- name: Build
4650
shell: bash
4751
run: |
48-
sudo bash build_own.sh "${{ matrix.bit }}"
49-
# - name: upload logs
50-
# uses: actions/upload-artifact@master
51-
# with:
52-
# name: logs
53-
# path: |
54-
# mpv-winbuild-cmake/build64/packages/mpv-prefix/src/mpv-stamp/mpv-build-*.log
55-
# mpv-winbuild-cmake/build64/packages/mujs-prefix/src/mujs-stamp/mujs-build-*.log
56-
# mpv-winbuild-cmake/build64/packages/libsrt-prefix/src/libsrt-stamp/libsrt-configure-*.log
52+
sudo bash build_own.sh "${{ matrix.bit }}" "${{ github.event.inputs.clean }}"
53+
# - name: upload logs
54+
# uses: actions/upload-artifact@master
55+
# if: always()
56+
# with:
57+
# name: logs
58+
# path: |
59+
# mpv-winbuild-cmake/build64/packages/mpv-prefix/src/mpv-stamp/mpv-*.log
5760

5861
- name: Upload artifact
5962
id: upload
6063
uses: kittaakos/upload-artifact-as-is@master
6164
with:
6265
path: mpv-winbuild-cmake/release/*.7z
6366

67+
publish_release:
68+
name: Publish release
69+
needs: build_mpv
70+
if: ${{ github.event.inputs.release }} != "false"
71+
runs-on: ubuntu-latest
72+
73+
steps:
74+
- name: Checkout
75+
uses: actions/checkout@v2
76+
- name: Download artifacts
77+
uses: actions/download-artifact@v2
78+
with:
79+
path: artifacts
80+
81+
- name: 'Get mpv latest commit sha'
82+
id: get_sha
83+
uses: mego22/actions-git-sha@main
84+
with:
85+
repo: "https://github.com/mpv-player/mpv.git"
86+
- name: Get current time
87+
run: |
88+
echo "long_time=$(date "+%Y-%m-%d %H:%M")" >> $GITHUB_ENV
89+
echo "short_time=$(date "+%Y-%m-%d")" >> $GITHUB_ENV
6490
- name: Create release
6591
uses: ncipollo/release-action@v1
66-
if: ${{ steps.upload.outcome == 'success' }}
6792
with:
68-
artifacts: "mpv-winbuild-cmake/release/*.7z"
93+
artifacts: "artifacts/*/*.7z"
6994
commit: main
7095
name: "MPV_OWN ${{ env.long_time }}"
7196
body: "MPV git commit: https://github.com/mpv-player/mpv/commit/${{ steps.get_sha.outputs.sha }}\nBuild Time: ${{ env.long_time }}"

build.sh

+6-8
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ main() {
1717
cd mpv-winbuild-cmake
1818
git checkout $branch
1919
gitdir=$(pwd)
20+
buildroot=$(pwd)
21+
isClean=$2
2022

21-
if [ -z "$2" ]; then
22-
buildroot=$(pwd)
23-
else
24-
buildroot=$2
25-
fi
2623
prepare
2724
if [ "$1" == "32" ]; then
2825
package "32" "i686"
@@ -45,8 +42,9 @@ package() {
4542
local bit=$1
4643
local arch=$2
4744

48-
if [ -d $buildroot/build$bit/mpv-$arch* ] ; then
49-
sudo rm -rf $buildroot/build$bit/mpv-$arch*
45+
if [ -n "$isClean" ]; then
46+
echo "Clean $bit-bit build files"
47+
sudo rm -rf $buildroot/build$bit
5048
fi
5149
build $bit $arch
5250
zip $bit $arch
@@ -71,7 +69,7 @@ build() {
7169
echo "Successfully compiled $bit-bit. Continue"
7270
else
7371
echo "Failed compiled $bit-bit. Stop"
74-
exit
72+
exit 1
7573
fi
7674
}
7775

build_own.sh

+6-8
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,9 @@ main() {
1717
cd mpv-winbuild-cmake
1818
git checkout $branch
1919
gitdir=$(pwd)
20+
buildroot=$(pwd)
21+
isClean=$2
2022

21-
if [ -z "$2" ]; then
22-
buildroot=$(pwd)
23-
else
24-
buildroot=$2
25-
fi
2623
prepare
2724
if [ "$1" == "32" ]; then
2825
package "32" "i686"
@@ -45,8 +42,9 @@ package() {
4542
local bit=$1
4643
local arch=$2
4744

48-
if [ -d $buildroot/build$bit/mpv-$arch* ] ; then
49-
sudo rm -rf $buildroot/build$bit/mpv-$arch*
45+
if [ -n "$isClean" ]; then
46+
echo "Clean $bit-bit build files"
47+
sudo rm -rf $buildroot/build$bit
5048
fi
5149
build $bit $arch
5250
zip $bit $arch
@@ -71,7 +69,7 @@ build() {
7169
echo "Successfully compiled $bit-bit. Continue"
7270
else
7371
echo "Failed compiled $bit-bit. Stop"
74-
exit
72+
exit 1
7573
fi
7674
}
7775

0 commit comments

Comments
 (0)