Use modern GitHub Actions

This commit is contained in:
iBug 2023-02-05 14:13:46 +08:00
parent c9672b8135
commit 1223f04dc9
2 changed files with 12 additions and 13 deletions

View File

@ -7,27 +7,23 @@ on:
schedule: schedule:
- cron: "0 12 * * 6" # 8 PM CST every Saturday - cron: "0 12 * * 6" # 8 PM CST every Saturday
permissions:
contents: write
jobs: jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v1 - uses: actions/checkout@v3
- run: | - run: |
python3 build.py python3 build.py
gzip -9 dist/*.txt gzip -9 dist/*.txt
- name: Generate release info - name: Generate release info
id: release-info id: release-info
run: python3 release-info.py run: python3 release-info.py
- uses: actions/create-release@v1 - uses: softprops/action-gh-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with: with:
name: ${{ steps.release-info.outputs.release_name }}
tag_name: ${{ steps.release-info.outputs.tag_name }} tag_name: ${{ steps.release-info.outputs.tag_name }}
release_name: ${{ steps.release-info.outputs.release_name }}
body_path: ${{ steps.release-info.outputs.body_path }} body_path: ${{ steps.release-info.outputs.body_path }}
- uses: csexton/release-asset-action@v2 files: 'dist/*'
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
pattern: 'dist/*'
release-url: ${{ steps.create_release.outputs.upload_url }}

View File

@ -6,16 +6,19 @@ import os
RELEASE_MARKDOWN_PATH = "release-info.md" RELEASE_MARKDOWN_PATH = "release-info.md"
OUTPUT_TARGET = None
def create_output(name, content, target=sys.stdout): def create_output(name, content):
print(f"::set-output name={name}::{content}", file=target) print(f"{name}={content}", file=OUTPUT_TARGET)
def main(): def main():
global OUTPUT_TARGET
if "GITHUB_ACTIONS" not in os.environ: if "GITHUB_ACTIONS" not in os.environ:
print("GitHub Actions environment expected but not found, abort.", file=sys.stderr) print("GitHub Actions environment expected but not found, abort.", file=sys.stderr)
sys.exit(1) sys.exit(1)
OUTPUT_TARGET = open(os.environ["GITHUB_OUTPUT"], "a")
# Credits: https://stackoverflow.com/a/1398742/5958455 # Credits: https://stackoverflow.com/a/1398742/5958455
# Depends on os.environ["TZ"] # Depends on os.environ["TZ"]