Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
9FS committed Sep 26, 2023
0 parents commit 225f4af
Show file tree
Hide file tree
Showing 14 changed files with 1,194 additions and 0 deletions.
177 changes: 177 additions & 0 deletions .github/workflows/on tag deploy on Github.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
name: On Tag Deploy on Github
env:
PROJECT_NAME: nHentai to PDF Server
PYTHON_VERSION: ^3.11.0
on:
push:
tags:
# - "[0-9]+.[0-9]+.[0-9]+"
- "*" # execute every time tag is pushed

jobs:
datetime:
name: Get Current Datetime
env:
working-directory: ${{github.workspace}}
runs-on: ubuntu-latest

steps:
- name: NOW
id: now
run: echo "NOW=$(date +'%Y-%m-%dT%H:%M:%S')" >> $GITHUB_OUTPUT # get datetime, save in NOW, push to output

- name: TODAY
id: today
run: echo "TODAY=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT # get date, save in TODAY, push to output

outputs: # set step output as job output so other jobs can access
NOW: ${{steps.now.outputs.NOW}}
TODAY: ${{steps.today.outputs.TODAY}}


create_release:
name: Create Release
env:
working-directory: ${{github.workspace}}
needs: datetime
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4 # makes repository structure available

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{env.PYTHON_VERSION}}

- name: Install Poetry
run: |
pip install poetry
poetry config virtualenvs.in-project true
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry install
- name: Check Project Version and Tag Match
run: |
project_version=$(poetry version --no-ansi | awk '{print $NF}')
tag=${GITHUB_REF#refs/tags/*}
if [ "$project_version" == "$tag" ]; then
exit 0
else
exit 1
fi
- name: Create Release
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
id: create_release
uses: actions/create-release@v1 # function that creates release
with: # parameters
body: # release text
draft: false
prerelease: false
release_name: ${{needs.datetime.outputs.TODAY}} ${{env.PROJECT_NAME}} ${{github.ref}} # release title
tag_name: ${{github.ref}} # release tag

outputs:
github_release: ${{steps.create_release.outputs.upload_url}}


build:
name: Build Executable for ${{matrix.os}}
env:
working-directory: ${{github.workspace}}
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- name: Checkout Repository
uses: actions/checkout@v4 # makes repository structure available

- name: Install Python
uses: actions/setup-python@v4
with:
python-version: ${{env.PYTHON_VERSION}}

- name: Install Poetry
run: |
pip install poetry
poetry config virtualenvs.in-project true
poetry config repositories.test-pypi https://test.pypi.org/legacy/
poetry install
- name: Install Pyinstaller
run: poetry run pip install pyinstaller # not `poetry add pyinstaller` because poetry will complain about pyinstaller's python dependency not being met

- name: Compile
run: poetry run pyinstaller --onefile "./src/main_outer.py" --clean --name "program"

- name: Cache Ubuntu Executable
if: ${{matrix.os=='ubuntu-latest'}}
uses: actions/cache/save@v3
with:
key: program.sh
path: ./dist/program

- name: Cache Windows Executable
if: ${{matrix.os=='windows-latest'}}
uses: actions/cache/save@v3
with:
key: program.exe
path: ./dist/program.exe


deploy:
name: Deploy on Github
env:
working-directory: ${{github.workspace}}
needs: [build, create_release, datetime]
runs-on: ${{matrix.os}}
strategy:
matrix:
os: [ubuntu-latest, windows-latest]

steps:
- name: Load Ubuntu Executable
if: ${{matrix.os=='ubuntu-latest'}}
uses: actions/cache/restore@v3
with:
key: program.sh
path: ./dist/program

- name: Load Windows Executable
if: ${{matrix.os=='windows-latest'}}
uses: actions/cache/restore@v3
with:
key: program.exe
path: ./dist/program.exe

- name: Parse Tag
id: parse_tag
run: echo "tag=${GITHUB_REF#refs/tags/*}" >> $GITHUB_OUTPUT # parse tag because github.ref provides tag as f"refs/tags/{tag}", in create_release it is parsed automatically idk
shell: bash # must be bash even on windows, because command to apply value to variable works differently in powershell

- name: Attach Ubuntu Executable to Release
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
if: ${{matrix.os=='ubuntu-latest'}}
uses: actions/upload-release-asset@v1
with:
asset_content_type: application
asset_name: ${{needs.datetime.outputs.TODAY}} ${{env.PROJECT_NAME}} ${{steps.parse_tag.outputs.tag}}.sh
asset_path: ./dist/program
upload_url: ${{needs.create_release.outputs.github_release}}

- name: Attach Windows Executable to Release
env:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
if: ${{matrix.os=='windows-latest'}}
uses: actions/upload-release-asset@v1
with:
asset_content_type: application
asset_name: ${{needs.datetime.outputs.TODAY}} ${{env.PROJECT_NAME}} ${{steps.parse_tag.outputs.tag}}.exe
asset_path: ./dist/program.exe
upload_url: ${{needs.create_release.outputs.github_release}}
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
*.exe
*.json
*.log
*.pyc
*.token
/doc_templates/
/hentai/
/log/
/src/test.py
downloadme.txt
21 changes: 21 additions & 0 deletions licence.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 구FS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading

0 comments on commit 225f4af

Please sign in to comment.