Skip to content

Upstream Sync and Create Release #10

Upstream Sync and Create Release

Upstream Sync and Create Release #10

Workflow file for this run

name: Check Upstream Tags and Create Release
on:
push:
branches:
- main # 你可以根据需要调整分支
workflow_dispatch:
jobs:
check-tags:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Git
run: |
git config --global user.name "Zach"
git config --global user.email "[email protected]"
- name: Fetch all tags from upstream
run: |
git remote add upstream https://github.com/Lakr233/NotchDrop
git fetch upstream --tags
- name: Filter and compare tags
id: check_tags
run: |
latest_local_tag=$(git tag --list | grep -v "AAPL" | sort -V | tail -n 1)
latest_upstream_tag=$(git ls-remote --tags upstream | grep -v "AAPL" | awk -F'/' '{print $3}' | grep -v '{}$' | sort -V | tail -n 1)
echo "Latest local tag: $latest_local_tag"
echo "Latest upstream tag: $latest_upstream_tag"
if [ "$latest_local_tag" != "$latest_upstream_tag" ]; then
echo new_release=true >> $GITHUB_OUTPUT
echo latest_upstream_tag=$latest_upstream_tag >> $GITHUB_OUTPUT
else
echo new_release=false >> $GITHUB_OUTPUT
fi
- name: Create GitHub Release
if: steps.check_tags.outputs.new_release == 'true'
uses: ncipollo/[email protected]
with:
tag: ${{ steps.check_tags.outputs.latest_upstream_tag }}
name: ${{ steps.check_tags.outputs.latest_upstream_tag }}
body: 'Automated release for tag ${{ steps.check_tags.outputs.latest_upstream_tag }}'
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}