Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
114 changes: 23 additions & 91 deletions .github/workflows/create-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ on:
type: boolean

jobs:
tag:
name: Create Version Tag
release:
name: Create Version Tag and Release
runs-on: ubuntu-latest

permissions:
Expand All @@ -41,102 +41,34 @@ jobs:
ref: ${{ github.event.inputs.branch || github.event.repository.default_branch }}
fetch-depth: 0

- name: Get target commit SHA
id: commit
run: |
if [ "${{ github.event.inputs.commit }}" = "HEAD" ] || [ -z "${{ github.event.inputs.commit }}" ]; then
COMMIT_SHA=$(git rev-parse HEAD)
else
COMMIT_SHA="${{ github.event.inputs.commit }}"
# Verify the commit exists
if ! git cat-file -e "$COMMIT_SHA^{commit}" 2>/dev/null; then
echo "Error: Commit $COMMIT_SHA does not exist"
exit 1
fi
fi
echo "sha=$COMMIT_SHA" >> $GITHUB_OUTPUT
echo "Target commit: $COMMIT_SHA"

- name: Get latest version tag
id: latest_version
uses: ./get-latest-semver-tag
with:
prefix: 'v'
default-version: 'v0.1.0'

- name: Calculate new version
id: new_version
uses: ./get-next-semver
- name: Tag and create semver release
id: tag-and-create-release
uses: ./tag-and-create-semver-release
with:
current-version: ${{ steps.latest_version.outputs.tag }}
branch: ${{ github.event.inputs.branch }}
commit: ${{ github.event.inputs.commit }}
increment-major: ${{ github.event.inputs.increment_major }}
increment-minor: ${{ github.event.inputs.increment_minor }}
prefix: 'v'
default-version: 'v0.1.0'
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Check if tag already exists
run: |
if git tag -l | grep -q "^${{ steps.new_version.outputs.version }}$"; then
echo "Error: Tag ${{ steps.new_version.outputs.version }} already exists"
exit 1
fi

- name: Create and push tags
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"

# Create and push the semver tag
git tag -a "${{ steps.new_version.outputs.version }}" ${{ steps.commit.outputs.sha }} -m "Release ${{ steps.new_version.outputs.version }}"
git push origin "${{ steps.new_version.outputs.version }}"

echo "✅ Created and pushed tag ${{ steps.new_version.outputs.version }} for commit ${{ steps.commit.outputs.sha }}"

# Create major version tag if major version is 1 or more
MAJOR=${{ steps.new_version.outputs.major }}

if [ "$MAJOR" -ge 1 ]; then
MAJOR_TAG="v${MAJOR}"
echo "Creating major version tag: $MAJOR_TAG"

# Delete existing major tag if it exists (force update)
if git tag -l | grep -q "^${MAJOR_TAG}$"; then
git tag -d "$MAJOR_TAG" || true
git push origin ":refs/tags/$MAJOR_TAG" || true
echo "Deleted existing major tag $MAJOR_TAG"
fi

# Create and push new major tag
git tag -a "$MAJOR_TAG" ${{ steps.commit.outputs.sha }} -m "Major version $MAJOR_TAG (latest: ${{ steps.new_version.outputs.version }})"
git push origin "$MAJOR_TAG"

echo "✅ Created and pushed major version tag $MAJOR_TAG"
else
echo "Major version is 0, skipping major version tag creation"
fi

- name: Create release with auto-generated notes
- name: Generate job summary
run: |
# Create release notes file with metadata
cat > release_notes.md << 'EOF'
## What's Changed

This release was created from commit ${{ steps.commit.outputs.sha }} on branch `${{ github.event.inputs.branch || github.event.repository.default_branch }}`.
cat >> $GITHUB_STEP_SUMMARY << 'EOF'
## 🎉 Release Created Successfully!

### Version Details
- **Previous version**: ${{ steps.latest_version.outputs.found == 'true' && steps.latest_version.outputs.tag || 'none' }}
- **New version**: ${{ steps.new_version.outputs.version }}
- **Version type**: ${{ steps.new_version.outputs.increment-type }} release
| Detail | Value |
|--------|-------|
| **Previous Version** | `${{ steps.tag-and-create-release.outputs.previous-version }}` |
| **New Version** | `${{ steps.tag-and-create-release.outputs.new-version }}` |
| **Increment Type** | `${{ steps.tag-and-create-release.outputs.increment-type }}` |
| **Target Commit** | `${{ steps.tag-and-create-release.outputs.target-commit }}` |
| **Release URL** | [${{ steps.tag-and-create-release.outputs.new-version }}](${{ steps.tag-and-create-release.outputs.release-url }}) |

EOF
### 📋 Summary

# Create release with auto-generated notes
gh release create "${{ steps.new_version.outputs.version }}" \
--title "${{ steps.new_version.outputs.version }}" \
--notes-file release_notes.md \
--generate-notes \
--latest \
--target "${{ steps.commit.outputs.sha }}"
Successfully created a **${{ steps.tag-and-create-release.outputs.increment-type }} release** from `${{ steps.tag-and-create-release.outputs.previous-version }}` to `${{ steps.tag-and-create-release.outputs.new-version }}`.

echo "✅ Created release ${{ steps.new_version.outputs.version }} with auto-generated notes"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
The release is now available at: ${{ steps.tag-and-create-release.outputs.release-url }}
EOF
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ close-issue/close-issue
comment-issue/comment-issue
get-latest-semver-tag/get-latest-semver-tag
get-next-semver/get-next-semver
tag-and-create-semver-release/tag-and-create-semver-release

# IDE files
.vscode/
Expand Down
13 changes: 11 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.PHONY: build clean test help build-create-issue build-find-issue build-close-issue build-comment-issue build-get-latest-semver-tag build-get-next-semver
.PHONY: build clean test help build-create-issue build-find-issue build-close-issue build-comment-issue build-get-latest-semver-tag build-get-next-semver build-tag-and-create-semver-release

# Default target
help:
Expand All @@ -9,7 +9,7 @@ help:
@echo " help - Show this help message"

# Build all actions
build: build-create-issue build-find-issue build-close-issue build-comment-issue build-get-latest-semver-tag build-get-next-semver
build: build-create-issue build-find-issue build-close-issue build-comment-issue build-get-latest-semver-tag build-get-next-semver build-tag-and-create-semver-release

build-create-issue:
@echo "Building create-issue..."
Expand All @@ -35,6 +35,10 @@ build-get-next-semver:
@echo "Building get-next-semver..."
cd get-next-semver && go build -o get-next-semver main.go

build-tag-and-create-semver-release:
@echo "Building tag-and-create-semver-release..."
cd tag-and-create-semver-release && go build -o tag-and-create-semver-release main.go

# Clean all built binaries
clean:
@echo "Cleaning built binaries..."
Expand All @@ -44,6 +48,7 @@ clean:
rm -f comment-issue/comment-issue
rm -f get-latest-semver-tag/get-latest-semver-tag
rm -f get-next-semver/get-next-semver
rm -f tag-and-create-semver-release/tag-and-create-semver-release

# Run tests for all actions and go-kit
test:
Expand All @@ -62,4 +67,8 @@ test:
@cd get-latest-semver-tag && go test -v ./...
@echo "Testing get-next-semver..."
@cd get-next-semver && go test -v ./...
@echo "Testing semveractions..."
@cd internal/semveractions && go test -v ./...
@echo "Testing tag-and-create-semver-release..."
@cd tag-and-create-semver-release && go test -v ./...
@echo "All tests completed successfully!"
11 changes: 1 addition & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,7 @@ For detailed documentation on each action, click the action name in the table ab

## Versioning

This repository follows [Semantic Versioning (SemVer)](https://semver.org/) for all releases:

- **MAJOR** version for incompatible API changes
- **MINOR** version for backwards-compatible functionality additions
- **PATCH** version for backwards-compatible bug fixes

Each release creates two types of tags:

1. **Full semantic version** (e.g., `v1.2.3`)
2. **Major version tag** (e.g., `v1`) - automatically updated to point to the latest release within that major version
This repository use [Semantic Versioning (SemVer)](https://semver.org/) for versioning. Each release will be tagged with its full version (e.g., `v1.2.3`). The latest release of each major version will also be tagged with `v{Major}` (e.g., `v1`) and that tag will move to the latest version as new versions are released.

## License

Expand Down
2 changes: 2 additions & 0 deletions go.work
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ go 1.24

use (
./internal/go-kit
./internal/semveractions
./create-issue
./find-issue
./close-issue
./comment-issue
./get-latest-semver-tag
./get-next-semver
./tag-and-create-semver-release
)
3 changes: 3 additions & 0 deletions internal/semveractions/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module github.com/half-ogre-games/hog-actions/internal/semveractions

go 1.24
Loading
Loading