Create MCPACK and release #10
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: | |
inputs: | |
tag: | |
description: 'Enter the tag to release' | |
required: true | |
default: 'v1.0.0' # You can set a default if you like | |
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 tag from workflow input | |
id: get_tag | |
run: | | |
# The tag will either come from the input (manual trigger) or from the git tag (auto trigger) | |
TAG=${{ github.event.inputs.tag || 'v1.0.0' }} | |
echo "Using specified 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 provided 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 }} |