dev/add-package-publisher #16

Merged
joshb merged 6 commits from dev/add-package-publisher into main 2022-11-11 01:29:24 +00:00
2 changed files with 50 additions and 3 deletions
Showing only changes of commit 5eb7303247 - Show all commits

14
Jenkinsfile vendored
View File

@ -21,9 +21,17 @@ node ('windows') {
bat """pyinstaller --noconfirm --onefile --windowed "./main.py" """ bat """pyinstaller --noconfirm --onefile --windowed "./main.py" """
} }
// Wrap Up - Archive the Generated Executables, Tear Down the Build System. // Wrap Up - Archive the Generated Executables
stage('Archive/Teardown') { stage('Archive') {
archiveArtifacts artifacts: "dist\\*.exe" // Provide Credentials to Upload to Gitea
withCredentials([
usernamePassword(credentialsId: 'gitea-jenkinsbot',
usernameVariable: 'GITEA_USER',
passwordVariable: 'GITEA_PASS')
]) {
// Publish the Latest
bat "python publish_package.py"
}
} }
} }

39
publish_package.py Normal file
View File

@ -0,0 +1,39 @@
################################################################################
"""
Publish the EXE as a package to Gitea.
"""
################################################################################
import os
import requests
OWNER = "jenkinsbot"
PKG_NAME = "ComputerKeeper-BUILD"
PKG_VERSION = "latest"
FILE_NAME = "main.exe"
AUTH_USER = os.getenv("GITEA_USER")
AUTH_PASS = os.getenv("GITEA_PASS")
HOST = "https://gitea.stanleysolutionsnw.com"
def main():
"""Attempt Deleting the Package, then Add the New Package with File."""
s = requests.Session()
s.auth = (AUTH_USER, AUTH_PASS)
# Delete Package
try:
s.delete(
f"{HOST}/api/packages/{OWNER}/generic/{PKG_NAME}/{PKG_VERSION}"
)
except Exception:
# Intentionally Overlook Issues Here
pass
# Add New Package
s.put(
(
f"{HOST}/api/packages/{OWNER}/generic/{PKG_NAME}/{PKG_VERSION}/" +
FILE_NAME
),
data=open(f"dist/{FILE_NAME}", 'rb').read(),
)