Skip to content

🔖 release(1.17.3): maybe MacOS universal2 arch #86

🔖 release(1.17.3): maybe MacOS universal2 arch

🔖 release(1.17.3): maybe MacOS universal2 arch #86

Workflow file for this run

name: Release
on:
push:
paths:
- src/constants.py
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: Prepare Version & Set Pre Release
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 ${{ runner.os }}
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 --target-arch=universal2 "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 }}