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 # Adjust the branch as needed | |
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 local tags | |
run: | | |
git fetch --tags | |
- name: Fetch all tags from upstream in temporary directory | |
run: | | |
mkdir temp_upstream_repo | |
cd temp_upstream_repo | |
git init | |
git remote add upstream https://github.com/Lakr233/NotchDrop | |
git fetch upstream --tags | |
latest_upstream_tag=$(git ls-remote --tags upstream | grep -v "AAPL" | awk -F'/' '{print $3}' | grep -v '{}$' | sort -V | tail -n 1) | |
echo "Latest upstream tag: $latest_upstream_tag" | |
echo latest_upstream_tag=$latest_upstream_tag >> $GITHUB_ENV | |
cd .. | |
- name: Get latest local tag | |
run: | | |
latest_local_tag=$(git tag --list | grep -v "AAPL" | sort -V | tail -n 1) | |
echo "Latest local tag: $latest_local_tag" | |
echo latest_local_tag=$latest_local_tag >> $GITHUB_ENV | |
- name: Compare tags | |
id: check_tags | |
run: | | |
if [ "$latest_local_tag" != "$latest_upstream_tag" ]; then | |
echo new_release=true >> $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: ${{ env.latest_upstream_tag }} | |
name: ${{ env.latest_upstream_tag }} | |
body: 'Automated release for tag ${{ env.latest_upstream_tag }}' | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |