Tweak build scripts, update README

This commit is contained in:
iBug 2020-07-27 01:19:19 +08:00
parent 5ca13387a5
commit 0df3228abd
5 changed files with 14 additions and 9 deletions

View File

@ -5,7 +5,7 @@ on:
branches: branches:
- master - master
schedule: schedule:
- cron: "0 20 * * 5" # 4 AM CST every Saturday - cron: "0 12 * * 6" # 8 PM CST every Saturday
jobs: jobs:
build: build:
@ -16,8 +16,6 @@ jobs:
- name: Generate release info - name: Generate release info
id: release-info id: release-info
run: python3 release-info.py run: python3 release-info.py
env:
TZ: Asia/Shanghai
- uses: actions/create-release@v1 - uses: actions/create-release@v1
id: create_release id: create_release
env: env:

1
.gitignore vendored
View File

@ -1,4 +1,5 @@
# Output # Output
release-info.md
*.pac *.pac
dist/ dist/

View File

@ -4,7 +4,7 @@ PAC scripts for proxies
## 使用 ## 使用
获取方式:[本仓库的 `dist` 分支](https://github.com/iBug/pac/tree/dist) 获取方式:[本仓库的 Releases](https://github.com/iBug/pac/releases/latest)
每周六 12:00 (UTC) 会自动使用 GitHub Actions 运行[生成脚本](build.py)从数据源获取 IP 地址列表并生成 PAC 文件。 每周六 12:00 (UTC) 会自动使用 GitHub Actions 运行[生成脚本](build.py)从数据源获取 IP 地址列表并生成 PAC 文件。

View File

@ -45,7 +45,7 @@ def main():
continue continue
except HTTPError: except HTTPError:
continue continue
filename = f"pac-{date}-{key}.txt" filename = f"pac-{key}.txt"
with open(os.path.join(OUT_DIR, filename), "w") as f: with open(os.path.join(OUT_DIR, filename), "w") as f:
f.write(code) f.write(code)
f.write(data) f.write(data)

View File

@ -13,21 +13,27 @@ def create_output(name, content, target=sys.stdout):
def main(): def main():
if "GITHUB_ACTIONS" not in os.environ:
print("GitHub Actions environment expected but not found, abort.", file=sys.stderr)
sys.exit(1)
# Credits: https://stackoverflow.com/a/1398742/5958455 # Credits: https://stackoverflow.com/a/1398742/5958455
# Depends on os.environ["TZ"] # Depends on os.environ["TZ"]
os.environ["TZ"] = "Etc/UTC"
time.tzset() time.tzset()
now = time.localtime(time.time()) now = time.localtime(time.time())
create_output("tag_name", "release-{}".format(time.strftime("%Y%m%d", now))) 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("release_name", "{} (Auto)".format(time.strftime("%Y-%m-%d", now)))
create_output("body_path", RELEASE_MARKDOWN_PATH) create_output("body_path", RELEASE_MARKDOWN_PATH)
# Produce the markdown # Produce the markdown
with open(RELEASE_MARKDOWN_PATH, "w") as f: with open(RELEASE_MARKDOWN_PATH, "w") as f:
body = "This is an automatic release created from GitHub Actions run {} on {} ({})".format( body = "This is an automatic release created from [GitHub Actions run {}](https://github.com/{}/actions/runs/{}) on {},".format(
os.environ.get("GITHUB_RUN_NUMBER", "<unknown>"), os.environ["GITHUB_RUN_NUMBER"],
os.environ["GITHUB_REPOSITORY"],
os.environ["GITHUB_RUN_ID"],
time.strftime("%B %-d, %Y", now), time.strftime("%B %-d, %Y", now),
os.environ.get("TZ", "UTC"),
) )
print(body, file=f) print(body, file=f)