release #9
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
name: release | |
on: | |
schedule: | |
- cron: "17 19 * * *" | |
workflow_dispatch: | |
defaults: | |
run: | |
shell: bash -e {0} | |
permissions: | |
contents: write | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Get the previous tag | |
id: previous_tag | |
run: | | |
prev_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "none") | |
if [ "$prev_tag" == "none" ]; then | |
echo "No tags found. Please create the first tag manually." | |
exit 1 | |
else | |
echo "Previous tag: $prev_tag" | |
fi | |
- name: Copy the json file from the previous tag | |
run: | | |
prev_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "none") | |
git archive -o $prev_tag.zip $prev_tag | |
unzip $prev_tag.zip -d /tmp | |
cp /tmp/bilibili-danmu-blocklist.json bilibili-danmu-blocklist-old.json | |
- uses: astral-sh/setup-uv@v5 | |
with: | |
version: "0.5.9" | |
enable-cache: true | |
- name: Set up Python | |
run: uv python install 3.13 | |
- name: Install the project | |
run: uv sync --all-extras --dev | |
- name: Compare diff between old json and new json file | |
run: | | |
uv run scripts/diff.py | |
if [ ! -e diff.md ]; then | |
echo "rules has not beed changed since last release." | |
exit 1 | |
fi | |
- name: Create bilibili-danmu-blocklist-output.json | |
run: uv run scripts/create_release_json.py | |
- name: Set Git Config | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Create a new tag | |
id: create_tag | |
run: | | |
tag_name=$(date +"%Y%m%d") | |
echo "tag_name=$tag_name" >> $GITHUB_OUTPUT | |
git tag -a $tag_name -m "Release $tag_name" | |
git push origin $tag_name | |
- uses: softprops/action-gh-release@v2 | |
with: | |
files: bilibili-danmu-blocklist-output.json | |
body_path: diff.md | |
tag_name: ${{ steps.create_tag.outputs.tag_name }} | |
make_latest: true |