Release Start #198
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: Release Start | |
on: | |
workflow_dispatch: | |
inputs: | |
channel: | |
required: true | |
type: choice | |
description: Channel of the release (alpha/beta/stable) | |
options: | |
- alpha | |
- beta | |
- stable | |
version: | |
required: false | |
description: force version of the release (e.g. 9.0.0) leave blank to increment automatically | |
jobs: | |
setup-release-branch: | |
timeout-minutes: 5 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout branch | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
ref: develop | |
fetch-depth: 0 | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: ".nvmrc" | |
cache: 'npm' | |
cache-dependency-path: package-lock.json | |
- name: Install packages | |
run: npm ci | |
# ############################################################ | |
# SETUP RELEASE_VERSION and RELEASE_BRANCH | |
- name: App version (stable, patch latest stable) | |
if: github.event.inputs.channel == 'stable' && !github.event.inputs.version | |
run: npm --workspaces version patch | |
- name: App version (stable, with a specific version) | |
if: github.event.inputs.channel == 'stable' && github.event.inputs.version | |
run: npm --workspaces version "${{ github.event.inputs.version }}" | |
# handle new "major" beta releases, e.g. 10.0, 11.0, 12.0 ... | |
- name: App version (alpha/beta, with new general version) | |
if: github.event.inputs.channel != 'stable' && github.event.inputs.version && !contains(github.event.inputs.version, "-${{ github.event.inputs.channel }}") | |
run: npm --workspaces version "${{ github.event.inputs.version }}-${{ github.event.inputs.channel }}.0" | |
# handle botched alpha/beta releases, e.g. for iterations that were merged before running release-publish | |
- name: App version (alpha/beta, with a specific version) | |
if: github.event.inputs.channel != 'stable' && github.event.inputs.version && contains(github.event.inputs.version, "-${{ github.event.inputs.channel }}") | |
run: npm --workspaces version "${{ github.event.inputs.version }}" | |
- name: App version (alpha/beta, patch latest) | |
if: github.event.inputs.channel != 'stable' && !github.event.inputs.version | |
run: npm --workspaces version --preid "${{ github.event.inputs.channel }}" prerelease | |
# ############################################################ | |
- name: Get version | |
shell: bash | |
run: | | |
echo "RELEASE_VERSION=$(node -e "console.log(require('./packages/insomnia/package.json').version)")" >> $GITHUB_ENV | |
echo "RELEASE_BRANCH=release/$(node -e "console.log(require('./packages/insomnia/package.json').version)")" >> $GITHUB_ENV | |
# - name: Git create branch locally # Check out the new branch | |
# run: git checkout -b ${{ env.RELEASE_BRANCH }} | |
- name: Create Branch # Create a branch if it doesn't exist | |
uses: peterjgrainger/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
branch: ${{ env.RELEASE_BRANCH }} | |
- name: Checkout branch | |
uses: actions/checkout@v4 | |
with: | |
ref: ${{ env.RELEASE_BRANCH }} | |
persist-credentials: false | |
- name: Configure Git user | |
id: configure_git_user | |
uses: Homebrew/actions/git-user-config@master | |
with: | |
username: ${{ (github.event_name == 'workflow_dispatch' && github.actor) || 'insomnia-infra' }} | |
# ############################################################ | |
# re-run the versioning steps to apply to the new branch | |
- name: (Re-run) App version (stable, patch latest stable) | |
if: github.event.inputs.channel == 'stable' && !github.event.inputs.version | |
run: npm --workspaces version patch | |
- name: (Re-run) App version (stable, with a specific version) | |
if: github.event.inputs.channel == 'stable' && github.event.inputs.version | |
run: npm --workspaces version "${{ github.event.inputs.version }}" | |
# handle new "major" beta releases, e.g. 10.0, 11.0, 12.0 ... | |
- name: (Re-run) App version (alpha/beta, with new general version) | |
if: github.event.inputs.channel != 'stable' && github.event.inputs.version && !contains(github.event.inputs.version, "-${{ github.event.inputs.channel }}") | |
run: npm --workspaces version "${{ github.event.inputs.version }}-${{ github.event.inputs.channel }}.0" | |
# handle botched alpha/beta releases, e.g. for iterations that were merged before running release-publish | |
- name: (Re-run) App version (alpha/beta, with a specific version) | |
if: github.event.inputs.channel != 'stable' && github.event.inputs.version && contains(github.event.inputs.version, "-${{ github.event.inputs.channel }}") | |
run: npm --workspaces version "${{ github.event.inputs.version }}" | |
- name: (Re-run) App version (alpha/beta, patch latest) | |
if: github.event.inputs.channel != 'stable' && !github.event.inputs.version | |
run: npm --workspaces version --preid "${{ github.event.inputs.channel }}" prerelease | |
# ############################################################ | |
- name: Git Commit | |
run: git commit -am "Bump app version to ${{ env.RELEASE_VERSION }}" | |
- name: Git Push changes | |
run: | | |
remote_repo="https://${GITHUB_ACTOR}:${RELEASE_GH_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" | |
git push "${remote_repo}" --follow-tags | |
env: | |
RELEASE_GH_TOKEN: ${{ secrets.RELEASE_GH_TOKEN }} | |
- name: Run the Action | |
uses: devops-infra/[email protected] | |
with: | |
github_token: ${{ secrets.RELEASE_GH_TOKEN }} | |
source_branch: ${{ env.RELEASE_BRANCH}} | |
target_branch: develop | |
title: ":rocket: ${{ env.RELEASE_VERSION}}" | |
body: | | |
**Automated pull request** | |
Artifacts build in progress... | |
draft: false |