Create MCPACK and release #6
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: Zip and Add to Release | |
on: | |
push: | |
tags: | |
- '*' | |
workflow_dispatch: # Allows manual triggering | |
jobs: | |
zip-and-release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v3 | |
- name: Set up Git user | |
run: | | |
git config --global user.name "github-actions" | |
git config --global user.email "[email protected]" | |
- name: Get the latest tag | |
id: get_tag | |
run: | | |
# Get the latest tag in the repository, not necessarily the one that triggered the action | |
TAG=$(git describe --tags --abbrev=0) | |
echo "Using latest tag: $TAG" | |
echo "TAG=$TAG" >> $GITHUB_ENV | |
- name: Zip the repository | |
run: | | |
zip -r $GITHUB_ENV.TAG.zip . | |
- name: Create a release if it doesn't exist | |
id: create_release | |
run: | | |
# Check if a release exists for the latest tag | |
RELEASE_EXISTS=$(gh release view $TAG --json tagName --jq ".tagName" || echo "false") | |
if [ "$RELEASE_EXISTS" == "false" ]; then | |
echo "Creating release for tag: $TAG" | |
gh release create $TAG $GITHUB_ENV.TAG.zip --title "Release $TAG" --notes "Release notes for $TAG" | |
else | |
echo "Release already exists for tag: $TAG" | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Upload the zip file as a release asset | |
uses: softprops/action-gh-release@v1 | |
with: | |
files: $GITHUB_ENV.TAG.zip | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |