-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
132 lines (128 loc) · 5.06 KB
/
release_publish-stable.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
130
131
132
name: 0. Release > Stable
concurrency:
group: ci-release-stable
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
train:
name: Train
description: 'If not the current primary release train, the prior major version for which to perform a new release'
required: false
default: ''
type: choice
options:
- ''
- v4
source-branch:
description: 'If starting a new cycle, or reversioning, the source branch to update the release branch from'
required: false
default: 'beta'
type: choice
options:
- beta # promotes beta to stable
- main # promotes canary to stable
- release # re-releases a stable version
# At cycle start we must always reset the release branch to beta.
is-cycle-start:
description: 'Whether this is the start of a new release cycle'
required: true
default: false
type: boolean
# downversion e.g. 5.4.0-alpha.1 => 5.3.1 happens when we use a canary, beta or later release to hotfix a stable
# upversion e.g. 5.3.1 => 5.4.0 happens when we re-release an existing stable as a new minor/major
# examples:
# Upversion: 5.3.1 => 5.4.0
# from-version: 5.3.1
# increment: minor
# Downversion: 5.4.0-alpha.1 => 5.3.1
# from-version: 5.3.0
# increment: patch
from-version:
description: 'When upversioning or downversioning, the version from which to increment to get the version number for the release'
type: string
increment:
description: 'Type of Version Bump To Perform (only used when upversioning or downversioning)'
required: true
default: 'patch'
type: choice
options:
- patch
- minor
- major
dryRun:
name: Dry Run
description: 'Whether to perform a dry run'
required: true
default: false
type: boolean
env:
TURBO_API: http://127.0.0.1:9080
TURBO_TOKEN: this-is-not-a-secret
TURBO_TEAM: myself
jobs:
release:
name: Perform Release
runs-on: ubuntu-latest
environment: deployment
steps:
- name: Enforce Branch
# Note: we always checkout release in actions/checkout, but this enforces
# good hygiene.
if: github.ref != 'refs/heads/main'
run: |
echo "Releases may only be performed from the main branch."
exit 1
- name: Desired Branch
id: desired-branch
env:
TRAIN: ${{ github.event.inputs.train }}
run: |
if [[ $TRAIN != "" ]]; then
echo "DESIRED_BRANCH=${{github.event.inputs.train}}-release" >> "$GITHUB_OUTPUT"
else
echo "DESIRED_BRANCH=release" >> "$GITHUB_OUTPUT"
fi
- uses: actions/checkout@eef61447b9ff4aafe5dcd4e0bbf5d482be7e7871 # v4
with:
fetch-tags: true
show-progress: false
token: ${{ secrets.GH_DEPLOY_TOKEN }}
fetch-depth: 3
ref: ${{ steps.desired-branch.outputs.DESIRED_BRANCH }}
## Ensure we have a full copy of the source branch
- run: git fetch origin ${{ github.event.inputs.source-branch }}
- run: git fetch origin --tags --depth=1
- name: Make sure git user is setup
run: |
git config --local user.email ${{ secrets.GH_DEPLOY_EMAIL }}
git config --local user.name ${{ secrets.GH_DEPLOY_NAME }}
- name: Reset the Release Branch
if: github.event.inputs.source-branch != 'release' && (github.event.inputs.is-cycle-start == 'true' || github.event.inputs.from-version != null)
run: git reset --hard origin/${{ github.event.inputs.source-branch }} && git push origin release -f
- uses: ./.github/actions/setup
with:
install: true
repo-token: ${{ secrets.GH_DEPLOY_TOKEN }}
- name: Publish New Release
# If we are not reversioning
# Then we do the default patch increment from the current branch state.
# This handles both start-of-cycle and bugfix releases.
if: github.event.inputs.from-version == null
run: bun release publish release --train=${{ github.event.inputs.train }} --dry-run=${{ github.event.inputs.dryRun }}
env:
FORCE_COLOR: 2
CI: true
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}
- name: Publish New Release (Reversion)
# If we are reversioning
# Then we increment from the branch with the supplied increment
# This handles both upversioning and downversioning
if: github.event.inputs.from-version != null
run: bun release publish release --train=${{ github.event.inputs.train }} --from=${{ github.event.inputs.from-version }} --increment=${{ github.event.inputs.increment }} --dry-run=${{ github.event.inputs.dryRun }}
env:
FORCE_COLOR: 2
CI: true
NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
GITHUB_AUTH: ${{ secrets.GITHUB_TOKEN }}