Skip to content

Commit

Permalink
fix: Update tag reading functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Lissy93 committed Jul 30, 2024
1 parent b09f06d commit a8413c1
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 9 deletions.
29 changes: 22 additions & 7 deletions .github/workflows/compile.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
runs-on: ubuntu-latest

steps:
- name: 📥 Checkout repository
- name: 🛎️ Checkout repository
uses: actions/checkout@v2

- name: 🐍 Set up Python
Expand Down Expand Up @@ -58,32 +58,46 @@ jobs:
github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success'
steps:
- name: 📥 Checkout repository
- name: 🛎️ Checkout repository
uses: actions/checkout@v2

- name: 🏷️ Download Tag Artifact
if: github.event_name == 'workflow_run'
uses: actions/download-artifact@v2
with:
name: new
name: tag
path: .
continue-on-error: true

- name: 🏷️ Determine Tag Name
id: determine_tag
run: |
TAG_NAME=$(git describe --tags --abbrev=0 2>/dev/null)
if [ "${{ github.event_name }}" == "workflow_run" ]; then
if [[ -n "${{ github.event.workflow_run.outputs.new_tag }}" ]]; then
TAG_NAME="${{ github.event.workflow_run.outputs.new_tag }}"
elif [[ -f tag.txt ]]; then
TAG_NAME=$(cat tag.txt)
else
TAG_NAME=$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0")
fi
else
NEW_TAG=$(git describe --tags --abbrev=0)
elif [ "${{ github.event_name }}" == "push" ] && [ -n "${{ github.ref }}" ] && [[ "${{ github.ref }}" == refs/tags/* ]]; then
TAG_NAME="${{ github.ref }}#refs/tags/"
fi
echo "Using tag $TAG_NAME"
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_ENV
- name: 🔍 Check if release already exists
id: check_release
run: |
if [ -z "$TAG_NAME" ]; then
echo "No tag name found, skipping release check"
exit 1
fi
if gh release view "$TAG_NAME" > /dev/null 2>&1; then
echo "Release for tag $TAG_NAME already exists."
exit 1
else
echo "Tag is present, valid and no existing releases exist. Continuing...."
fi
- name: 📤 Download PDF artifact
uses: actions/download-artifact@v2
Expand All @@ -98,3 +112,4 @@ jobs:
- name: 📄 Create GitHub Release
run: |
gh release create "$TAG_NAME" out/${{ env.PDF_NAME }} --title "Release $TAG_NAME" --notes "Generated CV PDF for release $TAG_NAME"
13 changes: 11 additions & 2 deletions .github/workflows/tag.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,15 @@ jobs:
if [ $(echo -e "$CURRENT_TAG\n$NEW_TAG" | sort -V | head -n1) = "$NEW_TAG" ] && [ "$CURRENT_TAG" != "$NEW_TAG" ]; then
echo "::warning::The new tag $NEW_TAG is lower than the current tag $CURRENT_TAG"
fi
- name: ❌ Ensure Tag Doesn't Already Exist
id: ensure_tag_doesnt_exist
run: |
NEW_TAG=${{ env.NEW_TAG }}
if git rev-parse "refs/tags/$NEW_TAG" >/dev/null 2>&1; then
echo "::error::The tag $NEW_TAG already exists."
exit 1
fi
- name: 🔑 Set Up Git User
run: |
Expand All @@ -69,10 +78,10 @@ jobs:
git tag -a "$NEW_TAG" -m "$DESCRIPTION"
echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
- name: Create Tag File
- name: 📄 Create Tag File
run: echo $NEW_TAG > tag.txt

- name: Upload Tag Artifact
- name: ⬆️ Upload Tag Artifact
uses: actions/upload-artifact@v4
with:
name: tag
Expand Down

0 comments on commit a8413c1

Please sign in to comment.