Bump checkout version and add debug log step to action #3
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 new release | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
ref: main | |
fetch-depth: 0 # Fetch full history to ensure we can compare versions properly | |
- name: Debug Git History | |
run: | | |
echo "Current Branch: $(git rev-parse --abbrev-ref HEAD)" | |
echo "Commit History:" | |
git log --oneline --graph --decorate --all | |
- name: Get previous commit hash (before HEAD) | |
id: previous_commit | |
run: | | |
# Get the commit hash before the most recent one | |
PREVIOUS_COMMIT=$(git log HEAD@{1} -1 --format=%H) | |
echo "commit_hash=$PREVIOUS_COMMIT" >> $GITHUB_OUTPUT | |
- name: Get the package.json version from previous commit | |
run: | | |
# Fetch the package.json version from the previous commit | |
BASE_VERSION=$(git show ${{ steps.previous_commit.outputs.commit_hash }}:package.json | jq -r .version) | |
echo "base_version=$BASE_VERSION" >> $GITHUB_OUTPUT | |
- name: Get the current package.json version (after merge) | |
run: | | |
# Extract the current package.json version at the HEAD | |
CURRENT_VERSION=$(jq -r .version package.json) | |
echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
- name: Compare versions | |
if: ${{ steps.previous_commit.outputs.commit_hash }} | |
run: | | |
if [ "${{ steps.previous_commit.outputs.base_version }}" != "${{ steps.previous_commit.outputs.current_version }}" ]; then | |
echo "Version has changed" | |
echo "version_changed=true" >> $GITHUB_OUTPUT | |
else | |
echo "Version did not change" | |
echo "version_changed=false" >> $GITHUB_OUTPUT | |
# Read version changelog | |
- id: get-changelog | |
if: steps.previous_commit.outputs.version_changed == 'true' | |
name: Get version changelog | |
uses: superfaceai/release-changelog-action@v1 | |
with: | |
path-to-changelog: CHANGELOG.md | |
version: ${{ env.CURRENT_VERSION }} | |
operation: read | |
# Commit changes | |
- name: Create tag | |
if: steps.previous_commit.outputs.version_changed == 'true' | |
run: | | |
git tag ${{ env.CURRENT_VERSION }} | |
# Push repository changes | |
- name: Push tag to repository | |
if: steps.previous_commit.outputs.version_changed == 'true' | |
env: | |
GITHUB_TOKEN: ${{ secrets.IKONO_TOKEN }} | |
run: | | |
git push --tags | |
# Update GitHub release with changelog | |
- name: Update GitHub release documentation | |
uses: softprops/action-gh-release@v1 | |
if: steps.previous_commit.outputs.version_changed == 'true' | |
with: | |
tag_name: ${{ env.CURRENT_VERSION }} | |
body: ${{ steps.get-changelog.outputs.changelog }} | |
## Pre-releases not currently supported | |
# prerelease: ${{ startsWith(github.event.inputs.release-type, 'pre') }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.IKONO_TOKEN }} |