-
Notifications
You must be signed in to change notification settings - Fork 0
170 lines (156 loc) · 7.52 KB
/
Copy pathreport_release.yml
File metadata and controls
170 lines (156 loc) · 7.52 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
on:
workflow_call:
inputs:
registry_release:
type: string
default: "false"
description: "Was the crate released on a registry"
docker_release:
type: string
default: "false"
description: "Was the crate released on docker"
binary_release:
type: string
default: "false"
description: "Was the crate released as binary"
npm_napi_release:
type: string
default: "false"
description: "Was the crate released as a napi binding"
installer_release:
type: string
default: "false"
description: "Was the crate released as installer"
working_directory:
type: string
default: "."
description: "The working directory"
env:
DISCORD_WEBHOOK: "${{ secrets.DISCORD_WEBHOOK }}"
jobs:
create-github-release:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
sparse-checkout: |
${{ inputs.working_directory }}/Cargo.toml
- id: derive_info
name: Derive info
shell: bash
run: |
PACKAGE=$(yq -p toml '.package.name' < ${{ inputs.working_directory }}/Cargo.toml)
VERSION=$(yq -p toml '.package.version' < ${{ inputs.working_directory }}/Cargo.toml)
PACKAGE_REF=$PACKAGE
VERSION_REF=$VERSION
if [[ $PACKAGE == *_launcher ]]; then
PACKAGE_REF=$(yq -p toml '.package.name' < ${{ inputs.working_directory }}/../Cargo.toml)
VERSION_REF=$(yq -p toml '.package.version' < ${{ inputs.working_directory }}/../Cargo.toml)
fi
if [[ $PACKAGE == *_installer ]]; then
PACKAGE_REF=$(yq -p toml '.package.name' < ${{ inputs.working_directory }}/../Cargo.toml)
VERSION_REF=$(yq -p toml '.package.version' < ${{ inputs.working_directory }}/../Cargo.toml)
fi
DATED_NIGHTLY=${{ (inputs.binary_release == 'true' || inputs.installer_release == 'true') && true || false }}
if [[ $GITHUB_REF == "refs/tags/$PACKAGE_REF-alpha-$VERSION_REF" ]] ; then
RELEASE_CHANNEL=alpha
elif [[ $GITHUB_REF == "refs/tags/$PACKAGE_REF-beta-$VERSION_REF" ]] ; then
RELEASE_CHANNEL=beta
elif [[ $GITHUB_REF == "refs/tags/$PACKAGE_REF-prod-$VERSION_REF" ]] ; then
RELEASE_CHANNEL=prod
else
RELEASE_CHANNEL=nightly
if [ "$DATED_NIGHTLY" = true ] ; then
VERSION=$(date +"%Y.%-m.%d")
fi
fi
echo release_channel=${RELEASE_CHANNEL} >> $GITHUB_OUTPUT
echo package=${PACKAGE} >> $GITHUB_OUTPUT
echo version=${VERSION} >> $GITHUB_OUTPUT
- id: generate_token
name: Generate token
uses: tibdex/github-app-token@v2.1.0
with:
app_id: ${{ secrets.FMSC_BOT_GITHUB_APP_ID }}
private_key: ${{ secrets.FMSC_BOT_GITHUB_APP_PRIVATE_KEY }}
- name: Bump version and push tag
id: tag_version
uses: mathieudutour/github-tag-action@v6.1
with:
github_token: "${{ steps.generate_token.outputs.token }}"
custom_tag: "${{ steps.derive_info.outputs.version }}"
tag_prefix: "${{ inputs.installer_release == 'true' && format('{0}-installer', steps.derive_info.outputs.package) || steps.derive_info.outputs.package }}-${{ steps.derive_info.outputs.release_channel }}-"
dry_run: "${{ steps.derive_info.outputs.release_channel == 'nightly' && 'false' || 'true' }}"
- name: Generate Docker URL
id: docker_registry_url
if: inputs.docker_release == 'true'
shell: bash
run: |
url="oreprohub.azurecr.io/${{ steps.derive_info.outputs.package }}:${{ steps.derive_info.outputs.version }}"
echo "value=$url" >> $GITHUB_OUTPUT
- name: Download artifacts
id: download_artifacts
if: inputs.binary_release == 'true'
uses: actions/download-artifact@v4
with:
pattern: release-binaries-*
path: binaries
merge-multiple: true
- name: Download installer artifacts
id: download_installer_artifacts
if: inputs.installer_release == 'true'
uses: actions/download-artifact@v4
with:
pattern: release-installer-signed
path: binaries
merge-multiple: true
- name: Generate NPM URL
id: npm_napi_url
if: inputs.npm_napi_release == 'true'
shell: bash
run: |
url=https://github.com/${{ github.repository_owner }}/${{ github.repository }}/pkgs/npm/${{ steps.derive_info.outputs.package }}
echo "value=$url" >> $GITHUB_OUTPUT
- name: Create a GitHub release
uses: ncipollo/release-action@v1
id: release
with:
token: ${{ steps.generate_token.outputs.token }}
tag: ${{ steps.tag_version.outputs.new_tag }}
name: ${{ inputs.installer_release == 'true' && format('{0}-installer', steps.derive_info.outputs.package) || steps.derive_info.outputs.package }} - ${{ steps.derive_info.outputs.release_channel }} - ${{ steps.derive_info.outputs.version }}
artifacts: "binaries/${{ format(((inputs.installer_release == 'true') && '{0}_installer' || '{0}'), steps.derive_info.outputs.package) }}/**/*"
skipIfReleaseExists: true
body: |
## Releases
* Docker: ${{ steps.docker_registry_url.outputs.value || 'NA' }}
* Binary: ${{ inputs.binary_release == 'true' && 'See artifacts' || 'NA' }}
* Installer: ${{ inputs.installer_release == 'true' && 'See artifacts' || 'NA' }}
* NPM Napi: ${{ steps.npm_napi_url.outputs.value || 'NA' }}
## Changelog
${{ steps.tag_version.outputs.changelog }}
- name: Construct discord embed links
shell: bash
id: links
run: |
declare -A raw_releases=()
raw_releases[docker]="${{ steps.docker_registry_url.outputs.value || 'na' }}|${{ steps.docker_registry_url.outputs.value }}"
raw_releases[binary]="${{ inputs.binary_release == 'true' && 'GH Release' || 'na' }}|${{ steps.release.outputs.html_url }}"
raw_releases[installer]="${{ inputs.installer_release == 'true' && 'GH Release' || 'na' }}|${{ steps.release.outputs.html_url }}"
raw_releases[npm]="${{ steps.npm_napi_url.outputs.value || 'na' }}|${{ steps.tag_version.outputs.new_tag }}"
release_links=()
for release_type in "${!raw_releases[@]}"; do
IFS=\| read -r release_link release <<< "${raw_releases[$release_type]}"
if [[ "$release_link" != "na" ]]; then
release_links+=( "{\"name\": \"${release_type/_/ }\", \"value\": \"[$release_link](${release})\"}" )
fi
done
echo fields=$(jq -c -n '$ARGS.positional' --jsonargs "${release_links[@]}") >> $GITHUB_OUTPUT
- name: Send Discord Notification
if: success() && env.DISCORD_WEBHOOK != ''
uses: Ilshidur/action-discord@master
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
DISCORD_EMBEDS: '[{"thumbnail": {"url": "https://avatars.githubusercontent.com/u/83515353?s=200&v=4"}, "title": "${{ steps.tag_version.outputs.new_tag }}", "url": "${{steps.release.outputs.html_url}}", "author": {"name": "${{ github.actor }}", "url": "https://github.com/${{ github.actor }}", "icon_url": "https://github.com/${{ github.actor }}.png"}, "fields": ${{ steps.links.outputs.fields }}}]'
with:
args: "Crate release"