name: Create Release on: workflow_dispatch: inputs: version: description: 'Version for this release (e.g. 1.0.0)' required: true default: '' version_type: description: 'Type of version increment' required: true default: 'patch' type: choice options: - major - minor - patch prerelease: description: 'Is this a pre-release?' required: true default: 'false' type: boolean description: description: 'Release description' required: false default: 'New release' jobs: create-release: runs-on: macos steps: - name: Checkout repository uses: actions/checkout@v3 with: lfs: true fetch-depth: 0 - name: Get or increment version id: versioning run: | # Fetch all tags git fetch --tags # Get the latest version tag, if any LATEST_TAG=$(git tag -l "v[0-9]*.[0-9]*.[0-9]*" | sort -V | tail -n1) # If no input version provided, increment the latest tag INPUT_VERSION="${{ github.event.inputs.version }}" if [ -z "$INPUT_VERSION" ] || [ "$INPUT_VERSION" = "" ]; then echo "No version specified, will calculate based on latest tag" if [ -z "$LATEST_TAG" ]; then # No previous version tag, start with 1.0.0 NEW_VERSION="1.0.0" echo "No previous version tags found, starting with 1.0.0" else # Strip 'v' prefix if it exists VERSION=${LATEST_TAG#v} # Split version into parts MAJOR=$(echo $VERSION | cut -d. -f1) MINOR=$(echo $VERSION | cut -d. -f2) PATCH=$(echo $VERSION | cut -d. -f3) # Increment based on version type case "${{ github.event.inputs.version_type }}" in major) MAJOR=$((MAJOR + 1)) MINOR=0 PATCH=0 ;; minor) MINOR=$((MINOR + 1)) PATCH=0 ;; *) # Default is patch PATCH=$((PATCH + 1)) ;; esac NEW_VERSION="${MAJOR}.${MINOR}.${PATCH}" echo "Incremented ${{ github.event.inputs.version_type }} version from ${VERSION} to ${NEW_VERSION}" fi else # Use provided version NEW_VERSION="${INPUT_VERSION}" echo "Using provided version: ${NEW_VERSION}" fi # Save the version for later steps echo "VERSION=v${NEW_VERSION}" >> $GITHUB_ENV echo "VERSION_NUMBER=${NEW_VERSION}" >> $GITHUB_ENV echo "::set-output name=version::v${NEW_VERSION}" echo "Final version: v${NEW_VERSION}" - name: Download latest artifacts run: | mkdir -p Artifacts echo "Downloading latest build artifacts..." # You can add specific download commands here if needed # For example, using curl to download from your CI system # List what we have after download echo "Available artifacts:" ls -la Artifacts/ || echo "No artifacts found" - name: Create Tag if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' run: | TAG="${{ env.VERSION }}" echo "Creating git tag: $TAG" # Configure git with token authentication git config --global user.email "actions@gitea.com" git config --global user.name "Gitea Actions" # Direct token approach - simplest method git remote set-url origin "https://goran:${{ secrets.GITEATOKEN }}@luckyrobots.com/goran/lyra_game_ue.git" # Set git to not prompt for input export GIT_TERMINAL_PROMPT=0 # Check if tag exists if ! git rev-parse "$TAG" >/dev/null 2>&1; then # Create tag without opening editor (-m flag) git tag -a "$TAG" -m "Release $TAG" # Push with timeout and debug echo "Pushing tag $TAG to origin..." git push --verbose origin "$TAG" || { echo "Error: Failed to push tag. Check your token permissions." exit 1 } echo "Successfully created and pushed tag: $TAG" else echo "Tag $TAG already exists, skipping tag creation" fi echo "RELEASE_TAG=$TAG" >> $GITHUB_ENV - name: Create Gitea Release if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' uses: https://gitea.com/actions/gitea-release-action@main with: token: ${{ secrets.GITEATOKEN }} tag_name: ${{ env.RELEASE_TAG }} title: "Release ${{ env.RELEASE_TAG }}" files: | Builds/*.zip Artifacts/*.zip