Create Release #10
This file contains hidden or 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 | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_type: | |
| description: 'Version type' | |
| required: true | |
| default: 'patch' | |
| type: choice | |
| options: | |
| - major | |
| - minor | |
| - patch | |
| deploy_to: | |
| description: 'Initial deployment target' | |
| required: true | |
| default: 'all' | |
| type: choice | |
| options: | |
| - all | |
| - staging | |
| - prod | |
| - none | |
| jobs: | |
| create-branch: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| outputs: | |
| new_version: ${{ steps.new-version.outputs.new_version }} | |
| branch_name: ${{ steps.new-version.outputs.branch_name }} | |
| steps: | |
| - name: Checkout main branch | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ vars.REPOSITORY_NAME || 'RoboFinSystems/roboledger-app' }} | |
| ref: main | |
| fetch-depth: 0 | |
| token: ${{ secrets.ACTIONS_TOKEN }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'npm' | |
| - name: Get current version | |
| id: current-version | |
| run: | | |
| CURRENT_VERSION=$(node -p "require('./package.json').version") | |
| echo "current_version=$CURRENT_VERSION" >> $GITHUB_OUTPUT | |
| - name: Calculate new version | |
| id: new-version | |
| run: | | |
| CURRENT_VERSION="${{ steps.current-version.outputs.current_version }}" | |
| VERSION_TYPE="${{ inputs.version_type }}" | |
| IFS='.' read -r major minor patch <<< "$CURRENT_VERSION" | |
| case "$VERSION_TYPE" in | |
| major) | |
| major=$((major + 1)) | |
| minor=0 | |
| patch=0 | |
| ;; | |
| minor) | |
| minor=$((minor + 1)) | |
| patch=0 | |
| ;; | |
| patch) | |
| patch=$((patch + 1)) | |
| ;; | |
| esac | |
| NEW_VERSION="${major}.${minor}.${patch}" | |
| BRANCH_NAME="release/${NEW_VERSION}" | |
| echo "new_version=$NEW_VERSION" >> $GITHUB_OUTPUT | |
| echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT | |
| - name: Configure Git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Update main branch version | |
| run: | | |
| CURRENT_VERSION="${{ steps.current-version.outputs.current_version }}" | |
| NEW_VERSION="${{ steps.new-version.outputs.new_version }}" | |
| echo "Updating main branch version from $CURRENT_VERSION to $NEW_VERSION" | |
| # Update version in package.json | |
| npm version "$NEW_VERSION" --no-git-tag-version | |
| # Install dependencies to update lock file | |
| npm install | |
| # Commit and push to main | |
| git add package.json package-lock.json | |
| git commit -m "Release v$NEW_VERSION" | |
| git push origin main | |
| - name: Create release branch | |
| run: | | |
| BRANCH_NAME="${{ steps.new-version.outputs.branch_name }}" | |
| echo "Creating release branch: $BRANCH_NAME" | |
| # Create new branch from updated main | |
| git checkout -b "$BRANCH_NAME" | |
| # Push the release branch | |
| git push origin "$BRANCH_NAME" | |
| echo "✅ Release branch $BRANCH_NAME created and pushed" | |
| create-tag: | |
| needs: create-branch | |
| permissions: | |
| contents: write | |
| uses: ./.github/workflows/tag-release.yml | |
| with: | |
| branch_ref: ${{ needs.create-branch.outputs.branch_name }} | |
| secrets: inherit | |
| deploy: | |
| needs: [create-branch, create-tag] | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 5 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| repository: ${{ vars.REPOSITORY_NAME || 'RoboFinSystems/roboledger-app' }} | |
| token: ${{ secrets.ACTIONS_TOKEN }} | |
| - name: Trigger deployment | |
| if: ${{ inputs.deploy_to != 'none' }} | |
| env: | |
| GH_TOKEN: ${{ secrets.ACTIONS_TOKEN }} | |
| run: | | |
| DEPLOY_TARGET="${{ inputs.deploy_to }}" | |
| TAG_NAME="${{ needs.create-tag.outputs.tag_name }}" | |
| echo "Triggering deployment to $DEPLOY_TARGET from git tag $TAG_NAME..." | |
| if [ "$DEPLOY_TARGET" = "staging" ]; then | |
| gh workflow run staging.yml --ref "$TAG_NAME" | |
| echo "Staging deployment triggered for tag $TAG_NAME" | |
| elif [ "$DEPLOY_TARGET" = "prod" ]; then | |
| gh workflow run prod.yml --ref "$TAG_NAME" | |
| echo "Production deployment triggered for tag $TAG_NAME" | |
| elif [ "$DEPLOY_TARGET" = "all" ]; then | |
| # Trigger staging first, then prod with delay | |
| # Both share 'roboledger-app-deploy' concurrency group, so prod queues behind staging | |
| gh workflow run staging.yml --ref "$TAG_NAME" | |
| echo "Staging deployment triggered for tag $TAG_NAME" | |
| echo "Waiting 30 seconds before triggering production (concurrency group will queue it)..." | |
| sleep 30 | |
| gh workflow run prod.yml --ref "$TAG_NAME" | |
| echo "Production deployment triggered - will start after staging completes" | |
| fi | |
| create-summary: | |
| needs: [create-branch, create-tag, deploy] | |
| if: always() | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 2 | |
| steps: | |
| - name: Create summary | |
| run: | | |
| echo "## 🚀 RoboLedger App Release Created" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Version:** ${{ needs.create-tag.outputs.version }}" >> $GITHUB_STEP_SUMMARY | |
| echo "**Tag:** \`${{ needs.create-tag.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "**Branch:** \`${{ needs.create-branch.outputs.branch_name }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "**Type:** ${{ inputs.version_type }}" >> $GITHUB_STEP_SUMMARY | |
| echo "**Deploy Target:** ${{ inputs.deploy_to }}" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Release URL:** ${{ needs.create-tag.outputs.release_url }}" >> $GITHUB_STEP_SUMMARY | |
| echo "**Live App:** [roboledger.ai](https://roboledger.ai)" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| if [ "${{ inputs.deploy_to }}" = "staging" ]; then | |
| echo "### Next Steps" >> $GITHUB_STEP_SUMMARY | |
| echo "1. Staging deployment has been triggered from tag ${{ needs.create-tag.outputs.tag_name }}" >> $GITHUB_STEP_SUMMARY | |
| echo "2. Test the release in staging environment" >> $GITHUB_STEP_SUMMARY | |
| echo "3. When ready for production, deploy from the git tag: \`gh workflow run prod.yml --ref ${{ needs.create-tag.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY | |
| elif [ "${{ inputs.deploy_to }}" = "prod" ]; then | |
| echo "### Next Steps" >> $GITHUB_STEP_SUMMARY | |
| echo "1. Production deployment has been triggered from tag ${{ needs.create-tag.outputs.tag_name }}" >> $GITHUB_STEP_SUMMARY | |
| echo "2. Monitor the deployment: \`gh run list --workflow=prod.yml\`" >> $GITHUB_STEP_SUMMARY | |
| echo "3. The git tag ${{ needs.create-tag.outputs.tag_name }} is now available for future deployments" >> $GITHUB_STEP_SUMMARY | |
| elif [ "${{ inputs.deploy_to }}" = "all" ]; then | |
| echo "### Next Steps" >> $GITHUB_STEP_SUMMARY | |
| echo "1. Both staging and production deployments have been triggered from tag ${{ needs.create-tag.outputs.tag_name }}" >> $GITHUB_STEP_SUMMARY | |
| echo "2. Monitor deployments: \`gh run list\`" >> $GITHUB_STEP_SUMMARY | |
| echo "3. The git tag ${{ needs.create-tag.outputs.tag_name }} is now available for future deployments" >> $GITHUB_STEP_SUMMARY | |
| else | |
| echo "### Next Steps" >> $GITHUB_STEP_SUMMARY | |
| echo "1. The release tag ${{ needs.create-tag.outputs.tag_name }} has been created but not deployed" >> $GITHUB_STEP_SUMMARY | |
| echo "2. To deploy to staging: \`gh workflow run staging.yml --ref ${{ needs.create-tag.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY | |
| echo "3. To deploy to production: \`gh workflow run prod.yml --ref ${{ needs.create-tag.outputs.tag_name }}\`" >> $GITHUB_STEP_SUMMARY | |
| fi |