下载文档并发布 #287
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# example 1: on push to master | |
name: 下载文档并发布 | |
on: | |
push: | |
paths: | |
- 'change.log' | |
schedule: | |
- cron: '0 15 * * *' | |
env: | |
TZ: 'Asia/Shanghai' | |
jobs: | |
build: | |
runs-on: ubuntu-22.04 | |
# permissions: | |
# contents: write | |
# packages: write | |
steps: | |
- name: Checkout Github Code | |
uses: actions/checkout@v3 | |
- name: 生成环境变量 | |
run: | | |
echo "GITHUB_MY_TAG=$(date +v%Y.%m.%d%H%M)" >> $GITHUB_ENV | |
echo "GITHUB_CACHE_KEY=$(date +v%Y-%m-%d-%H)" >> $GITHUB_ENV | |
echo "GITHUB_CACHE_KEY_D=$(date +v%Y-%m-%d-)" >> $GITHUB_ENV | |
echo "GITHUB_CACHE_KEY_M=$(date +v%Y-%m-)" >> $GITHUB_ENV | |
echo "GITHUB_CACHE_KEY_Y=$(date +v%Y-)" >> $GITHUB_ENV | |
- name: 输出生成环境变量 | |
run: | | |
echo ${{ env }} | |
- uses: actions/cache@v3 | |
id: cache | |
with: | |
path: | | |
output | |
dist | |
key: ${{ env.GITHUB_CACHE_KEY }} | |
restore-keys: | | |
${{ env.GITHUB_CACHE_KEY_D }} | |
${{ env.GITHUB_CACHE_KEY_M }} | |
${{ env.GITHUB_CACHE_KEY_Y }} | |
cache-key | |
- name: Autotag | |
uses: cardinalby/git-tag-action@master | |
env: | |
TAG: ${{ env.GITHUB_MY_TAG }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Set Up Golang Environment | |
uses: actions/setup-go@v4 | |
with: | |
go-version: 1.20.4 | |
cache: false | |
- name: 准备环境 | |
run: | | |
echo ${{ env.GITHUB_MY_TAG }} | |
sudo apt update | |
sudo apt install ttf-wqy-zenhei | |
fc-cache -f -v | |
ls -la | |
# 清除最新版的下载目录 | |
rm -rf output/goframe-latest | |
rm -rf output/goframe-latest-with-comments | |
# ls -la output | |
# 下载工具 | |
go install github.com/hailaz/doc2pdf/cmd/doc2pdf@latest | |
- name: download doc | |
run: | | |
doc2pdf gf -v=all | |
- name: show files | |
run: | | |
ls -la | |
ls -la dist | |
- name: Create Github Release | |
id: create_release | |
uses: softprops/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: '${{ env.GITHUB_MY_TAG }}' | |
name: '${{ env.GITHUB_MY_TAG }}' | |
body: '按需选择下载对应版本的文档' | |
draft: false | |
prerelease: false | |
files: | | |
dist/*.pdf |