Skip to content

Merge pull request #267 from monta-app/renovate/org.jetbrains.kotlinx… #91

Merge pull request #267 from monta-app/renovate/org.jetbrains.kotlinx…

Merge pull request #267 from monta-app/renovate/org.jetbrains.kotlinx… #91

Workflow file for this run

name: Release new version
on:
workflow_dispatch:
inputs:
version_bump:
description: 'Version bump type'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
push:
branches:
- main
# Prevent concurrent release workflows - second run will wait for first to complete
concurrency:
group: release
cancel-in-progress: false
permissions:
contents: write
jobs:
create-tag-and-build:
runs-on: ubuntu-latest
outputs:
new_version: ${{ steps.create_tag.outputs.new_version }}
deployment_start_time: ${{ steps.deployment_start.outputs.timestamp }}
steps:
- name: Capture deployment start time
id: deployment_start
run: echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0 # Fetch all tags
- name: Create new version tag
id: create_tag
run: |
# Configure git committer
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Get the latest tag
LATEST_TAG=$(git tag --sort=-version:refname | head -n 1)
echo "Latest tag: $LATEST_TAG"
# Parse version numbers (assuming format vMAJOR.MINOR.PATCH)
VERSION=${LATEST_TAG#v} # Remove 'v' prefix
MAJOR=$(echo "$VERSION" | cut -d. -f1)
MINOR=$(echo "$VERSION" | cut -d. -f2)
PATCH=$(echo "$VERSION" | cut -d. -f3)
# Determine version bump type (default to patch for push events)
BUMP_TYPE="${{ inputs.version_bump || 'patch' }}"
echo "Version bump type: $BUMP_TYPE"
# Increment version based on bump type
case "$BUMP_TYPE" in
major)
NEW_MAJOR=$((MAJOR + 1))
NEW_VERSION="v${NEW_MAJOR}.0.0"
;;
minor)
NEW_MINOR=$((MINOR + 1))
NEW_VERSION="v${MAJOR}.${NEW_MINOR}.0"
;;
patch)
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="v${MAJOR}.${MINOR}.${NEW_PATCH}"
;;
esac
echo "Creating new tag: $NEW_VERSION"
echo "new_version=$NEW_VERSION" >> "$GITHUB_OUTPUT"
# Create annotated tag
git tag "$NEW_VERSION" -m "Release $NEW_VERSION" -a
# Push the tag
git push origin "$NEW_VERSION"
echo "✅ Successfully created and pushed tag $NEW_VERSION"
- name: Set up JDK
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5
with:
java-version: '25'
distribution: 'corretto'
cache: 'gradle'
- name: Install dependencies
run: |
sudo apt update
sudo apt install libcurl4-openssl-dev
- name: Build with Gradle
run: ./gradlew prepareReleaseBinaries
- name: Upload x64 executable
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: changelog-cli-x64
path: build/release/changelog-cli-x64
- name: Upload ARM64 executable
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
with:
name: changelog-cli-arm64
path: build/release/changelog-cli-arm64
create-release:
runs-on: ubuntu-latest
needs: create-tag-and-build
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 0
- name: Download x64 artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: changelog-cli-x64
path: ./binaries
- name: Download ARM64 artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
with:
name: changelog-cli-arm64
path: ./binaries
- name: Give artifacts correct permissions
run: |
chmod +x ./binaries/changelog-cli-x64
chmod +x ./binaries/changelog-cli-arm64
- name: Capture deployment end time
id: deployment_end
run: echo "timestamp=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"
- name: Run changelog (using x64 binary)
id: changelog
run: ./binaries/changelog-cli-x64
env:
CHANGELOG_SERVICE_NAME: "Changelog Generator"
CHANGELOG_GITHUB_RELEASE: true
CHANGELOG_GITHUB_TOKEN: ${{ secrets.MONTA_BOT_TOKEN }}
CHANGELOG_JIRA_APP_NAME: "montaapp"
CHANGELOG_JIRA_EMAIL: ${{ secrets.JIRA_EMAIL }}
CHANGELOG_JIRA_TOKEN: ${{ secrets.JIRA_TOKEN }}
CHANGELOG_VERSION_MODE: "SemVer"
CHANGELOG_OUTPUT: "slack"
CHANGELOG_SLACK_TOKEN: ${{ secrets.SLACK_APP_TOKEN }}
CHANGELOG_SLACK_CHANNEL_NAME: "C02PDBL6GAU"
CHANGELOG_JOB_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
CHANGELOG_TRIGGERED_BY: ${{ github.actor }}
CHANGELOG_COMMENT_ON_PRS: true
CHANGELOG_COMMENT_ON_JIRA: true
CHANGELOG_STAGE: "production"
CHANGELOG_DEPLOYMENT_START_TIME: ${{ needs.create-tag-and-build.outputs.deployment_start_time }}
CHANGELOG_DEPLOYMENT_END_TIME: ${{ steps.deployment_end.outputs.timestamp }}
CHANGELOG_DEPLOYMENT_URL: ${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ needs.create-tag-and-build.outputs.new_version }}
- name: Upload x64 binary to release
uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./binaries/changelog-cli-x64
asset_name: changelog-cli-x64
tag: ${{ needs.create-tag-and-build.outputs.new_version }}
overwrite: true
- name: Upload ARM64 binary to release
uses: svenstaro/upload-release-action@29e53e917877a24fad85510ded594ab3c9ca12de # v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ./binaries/changelog-cli-arm64
asset_name: changelog-cli-arm64
tag: ${{ needs.create-tag-and-build.outputs.new_version }}
overwrite: true
update-action-repo:
runs-on: linux-arm64
needs: [create-release, create-tag-and-build]
steps:
- name: Setup SSH key
uses: webfactory/ssh-agent@e83874834305fe9a4a2997156cb26c5de65a8555 # v0.10.0
with:
ssh-private-key: ${{ secrets.SSH_KEY_MONTA_BOT }}
- name: Checkout changelog-cli-action
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
repository: monta-app/changelog-cli-action
ssh-key: ${{ secrets.SSH_KEY_MONTA_BOT }}
fetch-depth: 0
- name: Update version in action.yml
run: |
VERSION="${{ needs.create-tag-and-build.outputs.new_version }}"
sed -i "s|releases/download/v[0-9]*\.[0-9]*\.[0-9]*|releases/download/$VERSION|g" action.yml
# Show the diff
git diff action.yml
- name: Create or update PR
env:
GH_TOKEN: ${{ secrets.MONTA_BOT_TOKEN }}
run: |
VERSION="${{ needs.create-tag-and-build.outputs.new_version }}"
BRANCH_NAME="chore/update-cli-version"
# Configure git with Monta Bot credentials
git config user.name "Monta Bot"
git config user.email "bot@monta.app"
# Check if PR already exists
EXISTING_PR=$(gh pr list --head "$BRANCH_NAME" --state open --json number --jq '.[0].number' || echo "")
# Always start from main and create/update the branch
git checkout -B "$BRANCH_NAME"
git add action.yml
git commit -m "chore: update changelog-cli to $VERSION"
git push origin "$BRANCH_NAME" --force
# Prepare PR body
PR_BODY=$(cat <<EOF
Automatically generated PR to update changelog-cli version.
## Changes
- Update changelog-cli to **$VERSION**
## Release Notes
See the [changelog-cli $VERSION release](https://github.com/monta-app/changelog-cli/releases/tag/$VERSION) for details.
🤖 Automated by changelog-cli release workflow
_Updated: $(date -u '+%Y-%m-%d %H:%M:%S UTC')_
EOF
)
if [ -n "$EXISTING_PR" ]; then
echo "Found existing PR #$EXISTING_PR, updating it..."
gh pr edit "$EXISTING_PR" \
--title "chore: update changelog-cli to $VERSION" \
--body "$PR_BODY"
echo "✅ Updated existing PR #$EXISTING_PR"
else
echo "No existing PR found, creating new one..."
gh pr create \
--title "chore: update changelog-cli to $VERSION" \
--body "$PR_BODY" \
--base main \
--head "$BRANCH_NAME"
echo "✅ Created new PR"
fi