-
Notifications
You must be signed in to change notification settings - Fork 2k
129 lines (105 loc) · 4.83 KB
/
release-start.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
name: Release Start
run-name: Deploy ${{ github.event.inputs.version}} to ${{ github.event.inputs.channel }} channel by @${{ github.actor }}
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) if previous release was successful, this should auto increment
jobs:
setup-release-branch:
timeout-minutes: 5
runs-on: ubuntu-22.04
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 }}"
- name: App version (alpha/beta, patch latest alpha/beta)
if: github.event.inputs.channel != 'stable' && !github.event.inputs.version
run: npm --workspaces version --preid "${{ github.event.inputs.channel }}" prerelease
- name: App version (alpha/beta, with a specific version)
if: github.event.inputs.channel != 'stable' && github.event.inputs.version
run: npm --workspaces version "${{ github.event.inputs.version }}"
# ############################################################
- 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: 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 }}"
- name: (Re-run) App version (alpha/beta, patch latest alpha/beta)
if: github.event.inputs.channel != 'stable' && !github.event.inputs.version
run: npm --workspaces version --preid "${{ github.event.inputs.channel }}" prerelease
- name: (Re-run) App version (alpha/beta, with a specific version)
if: github.event.inputs.channel != 'stable' && github.event.inputs.version
run: npm --workspaces version "${{ github.event.inputs.version }}"
# ############################################################
- 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