-
Notifications
You must be signed in to change notification settings - Fork 1
135 lines (119 loc) · 4.28 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
name: Release
on:
push:
branches:
- main
workflow_dispatch:
concurrency:
group: ${{ github.ref }}-${{ github.workflow }}
cancel-in-progress: false
jobs:
prepare:
name: prepare
runs-on: ubuntu-latest
defaults:
run:
shell: bash
outputs:
CONTINUE: ${{ steps.set_continue.outputs.CONTINUE }}
LAST_COMMIT: ${{ steps.last-commit.outputs.message }}
PRE_RELEASE: ${{ steps.set_pre_release.outputs.PRE_RELEASE }}
VERSION: ${{ steps.get_version.outputs.VERSION }}
steps:
- name: Checkout repo
uses: actions/checkout@main
- name: Get Version
id: get_version
run: |
VERSION=$(grep VERSION "src/constants.py" | cut -d "=" -f 2 | sed 's/'\''//g' | sed 's/"//g' | sed 's/ //g' | sed 's/\r//')
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Set Continue
id: set_continue
run: |
REMOTE_VERSIONS=$(git ls-remote --tags -q | cut -d "/" -f 3)
for REMOTE_VERSION in ${REMOTE_VERSIONS[@]}; do
if [[ "${{ steps.get_version.outputs.VERSION }}" == "$REMOTE_VERSION" ]]; then
echo "Current version ${{ steps.get_version.outputs.VERSION }} is already released."
echo "CONTINUE=false" >>$GITHUB_OUTPUT
exit 0
fi
done
echo "CONTINUE=true" >>$GITHUB_OUTPUT
- name: Set Pre-Release
id: set_pre_release
run: |
VERSION_REGEX="^v[0-9]+\.[0-9]+\.[0-9]+$"
if [[ "${{ steps.get_version.outputs.VERSION }}" =~ $VERSION_REGEX ]]; then
echo "PRE_RELEASE=false" >> $GITHUB_OUTPUT
else
echo "PRE_RELEASE=true" >> $GITHUB_OUTPUT
fi
- name: Get last commit message
id: last-commit
run: echo "message=$(git log -1 --pretty=%s)" >> $GITHUB_OUTPUT
build:
name: build
needs: prepare
strategy:
fail-fast: false
matrix:
os:
- ubuntu
- windows
- macos
runs-on: ${{ matrix.os }}-latest
timeout-minutes: 10
if: ${{ needs.prepare.outputs.CONTINUE == 'true' }}
steps:
- name: get OS lowercase
id: get_os
shell: bash
run: echo "OS_LOWER=$(echo $RUNNER_OS | awk '{print tolower($0)}')" >> $GITHUB_ENV
- name: Checkout repo
uses: actions/checkout@main
- name: Install python
uses: actions/setup-python@main
with:
cache: pip
python-version: "3.12"
- name: Install dependacies
run: pip install -r requirements/requirements.txt && pip install pyinstaller
- name: Build for ${{ env.OS_LOWER }}
env:
OS_LOWER: ${{ env.OS_LOWER }}
run: pyinstaller --noconfirm --onefile --console --icon="assets/images/VNU_HCM_LOGO-256.ico" --name="VNULIB-Downloader-${{ env.OS_LOWER }}" --log-level="INFO" --add-data="src/:src/" --add-data="config-sample.yml:." --add-data="assets/images/error_page.jpg:assets/images/" --add-data="assets/utils/ascii_banner.txt:assets/utils/" --add-data="LICENSE:." --collect-data grapheme "main.py"
- name: Change permissions
if: runner.os == 'Linux' || runner.os == 'macOS'
run: chmod +x dist/VNULIB-Downloader-*
- name: Upload to artifact
env:
OS_LOWER: ${{ env.OS_LOWER }}
uses: actions/upload-artifact@main
with:
name: VNULIB-Downloader-${{ env.OS_LOWER }}
path: dist/VNULIB-Downloader-*
compression-level: 6
retention-days: 30
release:
name: Release
runs-on: ubuntu-latest
permissions:
contents: write
needs:
- prepare
- build
if: ${{ needs.prepare.outputs.CONTINUE == 'true' }}
steps:
- name: Download Artifact
uses: actions/download-artifact@main
- name: Upload to Release
uses: svenstaro/upload-release-action@master
with:
body: ${{ needs.prepare.outputs.LAST_COMMIT }}
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./VNULIB-Downloader-*/VNULIB-Downloader-*
release_name: VNULIB Downloader ${{ needs.prepare.outputs.VERSION }}
tag: ${{ needs.prepare.outputs.VERSION }}
file_glob: true
overwrite: false
prerelease: ${{ needs.prepare.outputs.PRE_RELEASE }}