Skip to content

Commit

Permalink
Add CI release and other trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
rsp4jack committed Feb 16, 2024
1 parent 5177749 commit a0038e8
Showing 1 changed file with 73 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/printcss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@ name: PrintCSS

on:
workflow_dispatch:
inputs:
tag_name:
description: "Tag name for release (empty for no release)"
required: false
default: contiguous
push:
branches: [ "main" ]
tags: ["v[0-9]+.[0-9]+.[0-9]+*"]
paths:
- README.md
- src/现代C++题目/**
pull_request:
branches: [ "main" ]
paths:
- README.md
- src/现代C++题目/**

jobs:
prepare:
Expand Down Expand Up @@ -119,3 +135,60 @@ jobs:
path: |
homework_problemtext.pdf
homework_full.pdf
release:
runs-on: ubuntu-latest
needs: build-printcss
permissions:
contents: write
steps:
- uses: actions/checkout@v4

- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: pdf
path: artifacts

- name: Archive and compress
run: |
find artifacts/ -printf "%P\n" | tar -cvf adocs.tar --no-recursion -C artifacts/ -T -
zstd -z -1 adocs.tar -o loser-homework-pdf.tar.zst
- if: github.event_name == 'workflow_dispatch'
run: echo "TAG_NAME=${{ github.event.inputs.tag_name }}" >> $GITHUB_ENV

- if: github.event_name == 'schedule'
run: echo 'TAG_NAME=contiguous' >> $GITHUB_ENV

- if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')
run: |
TAG_NAME=${{ github.ref }}
echo "TAG_NAME=${TAG_NAME#refs/tags/}" >> $GITHUB_ENV
echo "DRAFT=true" >> $GITHUB_ENV
- if: env.TAG_NAME == 'contiguous'
name: Delete previous contiguous
env:
GH_TOKEN: ${{ github.token }}
run: |
echo 'PRERELEASE=true' >> $GITHUB_ENV
gh release delete contiguous --yes || true
git config user.name github-actions
git config user.email github-actions@github.com
git push origin :contiguous || true
- name: Rename release files
run: |
mv loser-homework-pdf.tar.zst loser-homework-pdf-${{ env.TAG_NAME }}.tar.zst
- name: Wait a sec
run: sleep 2
- name: Release
uses: softprops/action-gh-release@v1
if: github.event_name != 'pull_request' && env.TAG_NAME != ''
with:
name: "Docs ${{ env.TAG_NAME }}"
prerelease: ${{ env.PRERELEASE != '' }}
files: loser-homework-docs-nightly.tar.zst
tag_name: ${{ env.TAG_NAME }}
draft: ${{ env.DRAFT != '' || null }}

0 comments on commit a0038e8

Please sign in to comment.