Skip to content

Auto Release for Last Month #3

Auto Release for Last Month

Auto Release for Last Month #3

Workflow file for this run

name: "自动发布 (月度)"
on:
schedule:
- cron: '0 0 1 * *'
workflow_dispatch:
jobs:
release:
runs-on: ubuntu-latest
steps:
- name: "检查存储库"
uses: actions/checkout@v3
- name: "获取当前时间"
id: date
run: |
current_month=$(date +'%m')
if [ "$current_month" == "01" ]; then
current_year=$(date +'%Y' --date="last year")
last_month="12"
else
current_year=$(date +'%Y')
last_month=$(date --date='1 month ago' +'%m')
fi
echo "current_year=${current_year}" >> $GITHUB_ENV
echo "last_month=${last_month}" >> $GITHUB_ENV
- name: "打包"
run: |
mkdir -p release
zip -r release/${current_year}-${last_month}.zip ${current_year}/${last_month}/
- name: "生成 Git tag"
id: tag
run: |
tag="${current_year}-${last_month}"
echo "Generated tag: $tag"
echo "TAG=${tag}" >> $GITHUB_ENV
- name: "发布"
uses: softprops/[email protected]
with:
tag_name: ${{ env.TAG }}
files: release/${current_year}-${last_month}.zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}