Repository navigation
155 lines (132 loc) · 5.42 KB
/
Copy pathrelease.yml
File metadata and controls
155 lines (132 loc) · 5.42 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
name: Main Release
on:
pull_request:
types: [closed]
branches:
- main
env:
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
permissions:
contents: write
# Serialize runs so concurrent triggers (e.g. a manual retry while a merge-triggered run is
# still in-flight) can't both compute and push the same "chore: release" commit/tag.
concurrency:
group: release-main
cancel-in-progress: false
jobs:
release:
if: |
github.event.pull_request.merged == true &&
(startsWith(github.head_ref, 'release/') || startsWith(github.head_ref, 'hotfix/'))
runs-on: macos-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
token: ${{ secrets.LICHTBLICK_GITHUB_TOKEN }}
ref: main
# Full history is required for the ancestry-based duplicate-release detection below.
fetch-depth: 0
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: 24
- name: Enable corepack
run: corepack enable yarn
- name: Install dependencies
run: yarn install --immutable
- name: Determine version bump type
id: bump_type
run: |
branch_name="$GITHUB_HEAD_REF"
if [[ "$branch_name" == hotfix/* ]]; then
echo "type=patch" >> "$GITHUB_ENV"
elif [[ "$branch_name" =~ ^release/major(/.*)?$ ]]; then
echo "type=major" >> "$GITHUB_ENV"
elif [[ "$branch_name" =~ ^release/minor(/.*)?$ ]]; then
echo "type=minor" >> "$GITHUB_ENV"
else
echo "ERROR: Invalid branch name: $branch_name
Expected one of:
- hotfix/<name>
- release/major/<anything>
- release/minor/<anything>" >&2
exit 1
fi
# See .github/workflows/scripts/check-existing-release.sh for what this detects and why.
- name: Check for existing release commit
env:
# github.ref/github.sha would be the ephemeral pull_request merge-preview ref/commit,
# which can be stale or gone once the PR is closed. merge_commit_sha is the actual,
# permanent commit that landed on main.
MERGE_COMMIT_SHA: ${{ github.event.pull_request.merge_commit_sha }}
run: bash .github/workflows/scripts/check-existing-release.sh
- name: Bump root version
if: env.already_released != 'true'
run: yarn version ${{ env.type }}
- name: Bump suite version
if: env.already_released != 'true'
working-directory: packages/suite
run: yarn version ${{ env.type }}
- name: Get new version
if: env.already_released != 'true'
id: get_version
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_ENV
- name: Update Sonar version
if: env.already_released != 'true'
run: sed -i "" "s/^sonar.projectVersion=.*/sonar.projectVersion=${{ env.version }}/" sonar-project.properties
- name: Commit and tag
if: env.already_released != 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git add package.json packages/suite/package.json yarn.lock sonar-project.properties
git commit -m "chore: release v${{ env.version }} [skip actions]"
git tag "v${{ env.version }}"
git push origin main --tags
# Retry path: the bump/commit/tag already landed on main in a previous attempt.
# Reset to the exact release commit (not origin/main's tip), in case later
# commits have since landed on main.
- name: Use existing release commit
if: env.already_released == 'true'
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git reset --hard "${{ env.release_commit_sha }}"
git tag -f "v${{ env.version }}"
git push --force origin "v${{ env.version }}"
- name: Build prod files
run: |
yarn run desktop:build:prod
yarn run web:build:prod
- name: Build Windows
run: yarn run package:win
- name: Build Linux
run: yarn run package:linux
- name: Build macOS
run: yarn run package:darwin
- name: Create web static files tarball
run: tar -czf dist/lichtblick-web.tar.gz -C web/.webpack .
- name: Create GitHub Release
uses: ncipollo/release-action@v1
with:
tag: "v${{ env.version }}"
name: "v${{ env.version }}"
commit: main
generateReleaseNotes: true
token: ${{ secrets.LICHTBLICK_GITHUB_TOKEN }}
artifacts: |
dist/lichtblick-${{ env.version }}-linux-amd64.deb
dist/lichtblick-${{ env.version }}-linux-x64.tar.gz
dist/lichtblick-${{ env.version }}-linux-arm64.deb
dist/lichtblick-${{ env.version }}-linux-arm64.tar.gz
dist/lichtblick-${{ env.version }}-mac-universal.dmg
dist/lichtblick-${{ env.version }}-win.exe
dist/lichtblick-web.tar.gz
dist/latest-linux.yml
dist/latest-mac.yml
dist/latest.yml
- name: Trigger SonarCloud analysis
run: gh workflow run sonarqube.yml --ref main
env:
GH_TOKEN: ${{ secrets.LICHTBLICK_GITHUB_TOKEN }}