forked from findechris/lms_mixcloud
-
Notifications
You must be signed in to change notification settings - Fork 10
141 lines (121 loc) · 5.39 KB
/
release.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
name: Release
on:
push:
branches:
- master
tags:
- '**'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
lfs: true
- name: Set version number (release build)
if: contains(github.ref, 'refs/tags/')
run: |
echo "VERSION=`echo ${GITHUB_REF##*/}`" >> $GITHUB_ENV
echo "RELEASE_CHANNEL=release" >> $GITHUB_ENV
echo "FOLDER=." >> $GITHUB_ENV
- name: Set version number (development build)
if: "!contains(github.ref, 'refs/tags/')"
run: |
echo "VERSION=`git describe --tags --abbrev=0`.`git rev-list $(git describe --tags --abbrev=0)..HEAD --count`-dev" >> $GITHUB_ENV
echo "RELEASE_CHANNEL=dev" >> $GITHUB_ENV
echo "FOLDER=dev-builds" >> $GITHUB_ENV
- name: Set yt-dlp version
run: |
echo "YT_VERSION=`cat yt-dlp.version`" >> $GITHUB_ENV
- name: Test if release number matches x.y
if: env.RELEASE_CHANNEL == 'release'
run: |
! [[ ${{ env.VERSION }} =~ ^[0-9]+.[0-9]+$ ]] && echo "Release tag must be in the form of x.y." && exit 1 || echo "Release tag format is correct"
- name: Create install XML file
uses: cuchi/[email protected]
with:
template: install.template.xml
output_file: install.xml
strict: true
- name: Download yt-dlp binaries for Linux
run: |
wget https://github.com/yt-dlp/yt-dlp/releases/download/${{ env.YT_VERSION }}/yt-dlp -P Bin && chmod +x Bin/yt-dlp
- name: Test yt-dlp operation with Mixcloud
run: |
./Bin/yt-dlp --skip-download --dump-json https://www.mixcloud.com/johndigweed/transitions-with-john-digweed-and-nickon-faith/ 1> /dev/null
- name: Download yt-dlp binaries for Windows and MacOS
if: env.RELEASE_CHANNEL == 'release'
run: |
wget https://github.com/yt-dlp/yt-dlp/releases/download/${{ env.YT_VERSION }}/yt-dlp.exe -P Bin
wget https://github.com/yt-dlp/yt-dlp/releases/download/${{ env.YT_VERSION }}/yt-dlp_macos -P Bin && chmod +x Bin/yt-dlp_macos
- name: Build package for Linux
run: |
zip -r lms_mixcloud-${{ env.VERSION }}-linux.zip . -x \*.zip \*.sh \*.git\* \*README\* \*sublime-\* \*.DS_Store\* \*.template.xml Bin\.gitkeep Bin/yt-dlp\.exe Bin/yt-dlp_macos
- name: Build packages for Windows and MacOS
if: env.RELEASE_CHANNEL == 'release'
run: |
zip -r lms_mixcloud-${{ env.VERSION }}-windows.zip . -x \*.zip \*.sh \*.git\* \*README\* \*sublime-\* \*.DS_Store\* \*.template.xml Bin\.gitkeep Bin/yt-dlp Bin/yt-dlp_macos
rm Bin/yt-dlp && mv Bin/yt-dlp_macos Bin/yt-dlp
zip -r lms_mixcloud-${{ env.VERSION }}-macos.zip . -x \*.zip \*.sh \*.git\* \*README\* \*sublime-\* \*.DS_Store\* \*.template.xml Bin\.gitkeep Bin/yt-dlp.exe
- name: Calculate SHA for Linux
run: |
echo "SHA_LINUX=$(shasum lms_mixcloud-${{ env.VERSION }}-linux.zip | awk '{print $1;}')" >> $GITHUB_ENV
- name: Calculate SHA for Windows and MacOS
if: env.RELEASE_CHANNEL == 'release'
run: |
echo "SHA_WINDOWS=$(shasum lms_mixcloud-${{ env.VERSION }}-windows.zip | awk '{print $1;}')" >> $GITHUB_ENV
echo "SHA_MACOS=$(shasum lms_mixcloud-${{ env.VERSION }}-macos.zip | awk '{print $1;}')" >> $GITHUB_ENV
- name: Create dev channel public XML file
uses: cuchi/[email protected]
with:
template: public.template.xml
output_file: public-dev.xml
strict: true
# variables: |
# all_platforms=true
- name: Create release public XML file
if: env.RELEASE_CHANNEL == 'release'
uses: cuchi/[email protected]
with:
template: public.template.xml
output_file: public.xml
strict: true
variables: |
all_platforms=true
- name: Switch branch, setup git for push
run: |
mv public*.xml /tmp
mv lms_mixcloud-${{ env.VERSION }}*.zip /tmp
git checkout gh-pages
cp /tmp/public*.xml .
cp /tmp/lms_mixcloud-${{ env.VERSION }}*.zip ${{ env.FOLDER }}/
git config --local user.email "[email protected]"
git config --local user.name "GitHub Actions"
if [ "${{ env.RELEASE_CHANNEL }}" == "dev" ]; then
git add ${{ env.FOLDER }}/lms_mixcloud-${{ env.VERSION }}*.zip
COMMIT_MESSAGE_TYPE="development build"
else
COMMIT_MESSAGE_TYPE="release"
fi
git commit -m "Github Actions ${COMMIT_MESSAGE_TYPE} ${{ env.VERSION }}" -a
- name: Push changes to gh-pages
uses: ad-m/github-push-action@master
with:
branch: gh-pages
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: Create release
if: env.RELEASE_CHANNEL == 'release'
id: create_release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
name: Release ${{ env.VERSION }}
draft: false
prerelease: false
files: |
lms_mixcloud-${{ env.VERSION }}-linux.zip
lms_mixcloud-${{ env.VERSION }}-windows.zip
lms_mixcloud-${{ env.VERSION }}-macos.zip