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: Create Release Asset | ||
on: | ||
workflow_dispatch: | ||
inputs: | ||
tag: | ||
description: 'Release tag' | ||
required: true | ||
default: 'v1.0.0' | ||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Step 1: Checkout the repository code | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
# Step 2: Prompt for the tag (using input from workflow_dispatch) | ||
- name: Get release tag | ||
id: get_tag | ||
run: echo "Release Tag: ${{ github.event.inputs.tag }}" | ||
# Step 3: Create a zip of the current repository excluding .git and .github | ||
- name: Zip repository excluding .git and .github | ||
run: | | ||
zip -r oreui-utilities.zip . -x "*.git*" -x ".github/*" | ||
# Step 4: Check if the release already exists | ||
- name: Check if tag exists and create the tag if it doesn't | ||
id: check_tag | ||
run: | | ||
TAG=${{ github.event.inputs.tag }} | ||
git fetch --tags | ||
if git rev-parse "$TAG" >/dev/null 2>&1; then | ||
echo "Tag $TAG already exists." | ||
else | ||
echo "Tag $TAG does not exist. Creating tag." | ||
git tag $TAG | ||
git push origin $TAG | ||
fi | ||
# Step 5: Create the release and upload the asset | ||
- name: Create Release and Upload Asset | ||
run: | | ||
TAG=${{ github.event.inputs.tag }} | ||
# Create release if it doesn't exist | ||
RELEASE=$(gh release view $TAG --json name --jq '.name' || echo "none") | ||
if [[ "$RELEASE" == "none" ]]; then | ||
echo "Creating release $TAG" | ||
gh release create "$TAG" oreui-utilities.zip --title "Release $TAG" --notes "Automated release for $TAG" --latest | ||
else | ||
echo "Release $TAG already exists" | ||
fi | ||
# Step 6: Logout from GitHub CLI | ||
- name: Logout from GitHub CLI | ||
run: gh auth logout -y |