debug: ci #11
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: 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: Debug Local Tags | |
run: | | |
echo "Local tags:" | |
git tag --list | sort -V | |
- name: Debug Upstream Tags | |
run: | | |
echo "Upstream tags:" | |
git ls-remote --tags upstream | awk -F'/' '{print $3}' | grep -v '{}$' | sort -V | |
- 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 | |
- name: List all local tags for debugging | |
if: steps.check_tags.outputs.new_release == 'false' | |
run: | | |
echo "All local tags:" | |
git tag --list | sort -V | |
- name: List all upstream tags for debugging | |
if: steps.check_tags.outputs.new_release == 'false' | |
run: | | |
echo "All upstream tags:" | |
git ls-remote --tags upstream | awk -F'/' '{print $3}' | grep -v '{}$' | sort -V | |
- 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 }} |