Skip to content

Commit

Permalink
Tweak build scripts, update README
Browse files Browse the repository at this point in the history
  • Loading branch information
iBug committed Jul 26, 2020
1 parent 5ca1338 commit 0df3228
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
branches:
- master
schedule:
- cron: "0 20 * * 5" # 4 AM CST every Saturday
- cron: "0 12 * * 6" # 8 PM CST every Saturday

jobs:
build:
Expand All @@ -16,8 +16,6 @@ jobs:
- name: Generate release info
id: release-info
run: python3 release-info.py
env:
TZ: Asia/Shanghai
- uses: actions/create-release@v1
id: create_release
env:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Output
release-info.md
*.pac
dist/

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 文件。

Expand Down
2 changes: 1 addition & 1 deletion build.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def main():
continue
except HTTPError:
continue
filename = f"pac-{date}-{key}.txt"
filename = f"pac-{key}.txt"
with open(os.path.join(OUT_DIR, filename), "w") as f:
f.write(code)
f.write(data)
Expand Down
14 changes: 10 additions & 4 deletions release-info.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,21 +13,27 @@ def create_output(name, content, target=sys.stdout):


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
# Depends on os.environ["TZ"]
os.environ["TZ"] = "Etc/UTC"
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("release_name", "{} (Auto)".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>"),
body = "This is an automatic release created from [GitHub Actions run {}](https://github.com/{}/actions/runs/{}) on {},".format(
os.environ["GITHUB_RUN_NUMBER"],
os.environ["GITHUB_REPOSITORY"],
os.environ["GITHUB_RUN_ID"],
time.strftime("%B %-d, %Y", now),
os.environ.get("TZ", "UTC"),
)
print(body, file=f)

Expand Down

1 comment on commit 0df3228

@68595959
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty good...

Please sign in to comment.