mirror of
https://github.com/iBug/pac.git
synced 2025-07-13 21:02:16 +08:00
Try uploading built content to Releases
This commit is contained in:
parent
209345282f
commit
5ca13387a5
30
.github/workflows/build.yml
vendored
30
.github/workflows/build.yml
vendored
@ -5,21 +5,29 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
schedule:
|
schedule:
|
||||||
- cron: "0 12 * * 6" # 4 AM CST every Saturday
|
- cron: "0 20 * * 5" # 4 AM CST every Saturday
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v1
|
- uses: actions/checkout@v1
|
||||||
- name: Prepare build
|
|
||||||
run:
|
|
||||||
git clone --branch=dist "https://${GITHUB_ACTOR}:${{ secrets.GITHUB_TOKEN }}@github.com/${GITHUB_REPOSITORY}.git" dist
|
|
||||||
- run: python3 build.py
|
- run: python3 build.py
|
||||||
- name: Push back to GitHub
|
- name: Generate release info
|
||||||
run: |
|
id: release-info
|
||||||
cd dist
|
run: python3 release-info.py
|
||||||
git add --all
|
env:
|
||||||
git -c user.name=GitHub -c user.email=noreply@github.com commit \
|
TZ: Asia/Shanghai
|
||||||
-m "Auto build from GitHub Actions run ${GITHUB_RUN_NUMBER}"
|
- uses: actions/create-release@v1
|
||||||
git push
|
id: create_release
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
tag_name: ${{ steps.release-info.outputs.tag_name }}
|
||||||
|
release_name: ${{ steps.release-info.outputs.release_name }}
|
||||||
|
body_path: ${{ steps.release-info.outputs.body_path }}
|
||||||
|
- uses: csexton/release-asset-action@v2
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
pattern: 'dist/*'
|
||||||
|
release-url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
3
build.py
3
build.py
@ -36,8 +36,7 @@ def main():
|
|||||||
code = f.read()
|
code = f.read()
|
||||||
code = code.replace("@@TIME@@", now.isoformat()[:-7])
|
code = code.replace("@@TIME@@", now.isoformat()[:-7])
|
||||||
|
|
||||||
if not os.path.exists(OUT_DIR):
|
os.makedirs(OUT_DIR, mode=0o755, exist_ok=True)
|
||||||
os.mkdir(OUT_DIR, mode=0o755)
|
|
||||||
for key in SOURCES:
|
for key in SOURCES:
|
||||||
print(f"Generating PAC script from source {key}")
|
print(f"Generating PAC script from source {key}")
|
||||||
try:
|
try:
|
||||||
|
36
release-info.py
Executable file
36
release-info.py
Executable file
@ -0,0 +1,36 @@
|
|||||||
|
#!/usr/bin/python3
|
||||||
|
|
||||||
|
import sys
|
||||||
|
import time
|
||||||
|
import os
|
||||||
|
|
||||||
|
|
||||||
|
RELEASE_MARKDOWN_PATH = "release-info.md"
|
||||||
|
|
||||||
|
|
||||||
|
def create_output(name, content, target=sys.stdout):
|
||||||
|
print(f"::set-output name={name}::{content}", file=target)
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
# Credits: https://stackoverflow.com/a/1398742/5958455
|
||||||
|
# Depends on os.environ["TZ"]
|
||||||
|
time.tzset()
|
||||||
|
now = time.localtime(time.time())
|
||||||
|
|
||||||
|
create_output("tag_name", "release-{}".format(time.strftime("%Y%m%d", now)))
|
||||||
|
create_output("release_name", "Release {}".format(time.strftime("%Y-%m-%d", now)))
|
||||||
|
create_output("body_path", RELEASE_MARKDOWN_PATH)
|
||||||
|
|
||||||
|
# Produce the markdown
|
||||||
|
with open(RELEASE_MARKDOWN_PATH, "w") as f:
|
||||||
|
body = "This is an automatic release created from GitHub Actions run {} on {} ({})".format(
|
||||||
|
os.environ.get("GITHUB_RUN_NUMBER", "<unknown>"),
|
||||||
|
time.strftime("%B %-d, %Y", now),
|
||||||
|
os.environ.get("TZ", "UTC"),
|
||||||
|
)
|
||||||
|
print(body, file=f)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
Loading…
Reference in New Issue
Block a user