-
Notifications
You must be signed in to change notification settings - Fork 5
150 lines (128 loc) · 4.4 KB
/
CD-create-release.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
name: "Create Release"
on:
workflow_dispatch:
inputs:
release_type:
type: choice
description: Release type
options:
- patch
- minor
- major
- prepatch
- preminor
- premajor
- prerelease
include:
type: choice
description: Include
options:
- npm packages + Docker image
- npm packages only
build_secret:
type: string
description: Build secret
jobs:
check-user-permissions:
runs-on: ubuntu-22.04
steps:
- name: Check user permission
uses: stjude/proteinpaint/.github/actions/check-user-permissions@master
with:
BUILD_SECRET: ${{ secrets.BUILD_SECRET }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
INPUT_BUILD_SECRET: ${{ github.event.inputs.build_secret }}
publish-npm:
needs: check-user-permissions
runs-on: ubuntu-22.04
permissions:
contents: write
packages: write
timeout-minutes: 20
outputs:
updated_rust: ${{ steps.version_bump.outputs.updated_rust }}
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.PAT }}
- name: Fetch All Tags
run: git fetch --all --tags
# Setup .npmrc file to publish to GitHub Packages
- uses: actions/setup-node@v3
with:
cache: 'npm'
node-version: '20'
registry-url: 'https://registry.npmjs.org'
scope: '@sjcrh'
- run: npm ci
- name: Run version bump
id: version_bump
run: |
exclude="";
if [ "${{ github.event.inputs.include }}" = "npm packages only" ]; then
exclude="-x=container";
fi
. ./build/ci-version-update.sh ${{ github.event.inputs.release_type }} -w $exclude
echo "::set-output name=branch::$BRANCH"
if [[ "$BRANCH" != "master" ]]; then
echo "::set-output name=draft::true"
echo "::set-output name=prerelease::true"
else
echo "::set-output name=draft::false"
echo "::set-output name=prerelease::false"
fi
echo "::set-output name=tag_name::$TAG"
./build/ci-npm-publish.sh "$UPDATED"
if [[ $UPDATED == *"rust"* ]]; then
echo "::set-output name=updated_rust::true"
else
echo "::set-output name=updated_rust::false"
fi
CHANGES="[CHANGELOG.md](https://github.com/stjude/proteinpaint/blob/master/CHANGELOG.md)"
echo "::set-output name=latest_release_changes::$CHANGES"
env:
NODE_AUTH_TOKEN: ${{ secrets.NPMJS_TOKEN }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.version_bump.outputs.tag_name }}
release_name: ${{ steps.version_bump.outputs.tag_name }}
body: |
${{ steps.version_bump.outputs.latest_release_changes }}
draft: ${{ steps.version_bump.outputs.draft }}
prerelease: ${{ steps.version_bump.outputs.prerelease }}
rust-build:
if: needs.publish-npm.outputs.updated_rust == 'true'
needs: publish-npm
uses: ./.github/workflows/CD-rust-build.yml
upload-rust-assets:
needs: rust-build
runs-on: ubuntu-22.04
steps:
- name: Upload rust assets
uses: stjude/proteinpaint/.github/actions/upload-rust-assets@master
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
publish-docker-no-new-rust-module:
if: needs.publish-npm.outputs.updated_rust == 'false' && github.event.inputs.include == 'npm packages + Docker image'
needs: publish-npm
runs-on: ubuntu-22.04
steps:
- name: Publish docker image
uses: stjude/proteinpaint/.github/actions/publish-docker@master
with:
PAT: ${{ secrets.PAT }}
GITHUB_ACTOR: ${{ github.actor }}
publish-docker-with-new-rust-module:
if: github.event.inputs.include == 'npm packages + Docker image'
needs: upload-rust-assets
runs-on: ubuntu-22.04
steps:
- name: Publish docker image
uses: stjude/proteinpaint/.github/actions/publish-docker@master
with:
PAT: ${{ secrets.PAT }}
GITHUB_ACTOR: ${{ github.actor }}