-
Notifications
You must be signed in to change notification settings - Fork 0
154 lines (137 loc) · 5.45 KB
/
publish_release.yaml
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
name: Publish a release
on:
# Trigger this release via the GitHub Actions interface for this workflow
workflow_dispatch:
env:
PUBLISH_GIT_USERNAME: "AppSignal release bot"
PUBLISH_GIT_EMAIL: "[email protected]"
jobs:
build:
name: "Build the release"
runs-on: ${{matrix.runner}}
strategy:
fail-fast: true
matrix:
include:
- runner: ubuntu-22.04
target: "x86_64-unknown-linux-gnu"
- runner: ubuntu-22.04
target: "x86_64-unknown-linux-musl"
- runner: ubuntu-22.04
target: "aarch64-unknown-linux-gnu"
- runner: ubuntu-22.04
target: "aarch64-unknown-linux-musl"
- runner: macos-14
target: "x86_64-apple-darwin"
- runner: macos-14
target: "aarch64-apple-darwin"
steps:
- name: "Checkout the project"
uses: actions/checkout@v4
with:
path: "main"
- name: "Checkout Mono"
uses: actions/checkout@v4
with:
repository: "appsignal/mono"
path: "mono"
- name: "Install Cross"
run: |
cargo install cross
# Linux targets will cross compile on Docker images used by Cross.
- name: "Login to Docker Hub"
if: matrix.runner == 'ubuntu-22.04'
uses: docker/login-action@v3
with:
username: ${{secrets.PUBLISH_DOCKERHUB_USERNAME}}
password: ${{secrets.PUBLISH_DOCKERHUB_TOKEN}}
# macOS targets do not build using a Cross image, so they may need to
# download the target for their architecture.
- name: "Install macOS architecture target"
if: matrix.runner == 'macos-14'
working-directory: "./main"
run: |
rustup target add "${{matrix.target}}"
# The version number needs to be written to the project's `Cargo.toml`
# file before building the release.
- name: "Write new version number"
working-directory: "./main"
run: |
../mono/bin/mono publish --no-git --no-package-push --yes
- name: "Build artifact"
working-directory: "./main"
run: |
script/build_artifact "${{matrix.target}}"
# Temporarily store the build artifact as a GitHub Action artifact to
# move it to the next job.
- name: "Store build artifact"
uses: actions/upload-artifact@v4
with:
name: "${{matrix.target}}"
path: "main/release/${{matrix.target}}.tar.gz"
retention-days: 1
if-no-files-found: error
publish:
name: "Publish the release"
needs:
- build
runs-on: ubuntu-22.04
steps:
- name: "Checkout the project"
uses: actions/checkout@v4
with:
ssh-key: "${{secrets.PUBLISH_DEPLOY_KEY}}"
path: "main"
- name: "Checkout Mono"
uses: actions/checkout@v4
with:
repository: "appsignal/mono"
path: "mono"
- name: "Configure Git"
run: |
export PUBLISH_GIT_SSH_PATH="$HOME/.ssh"
export PUBLISH_GIT_SIGN_KEY_PATH="$HOME/.ssh/sign_key"
mkdir -p "$PUBLISH_GIT_SSH_PATH"
echo "${{secrets.PUBLISH_GIT_SIGN_KEY}}" > "$PUBLISH_GIT_SIGN_KEY_PATH"
echo "${{secrets.PUBLISH_GIT_SIGN_PUBLIC_KEY}}" > "$PUBLISH_GIT_SIGN_KEY_PATH.pub"
chmod 600 "$PUBLISH_GIT_SIGN_KEY_PATH"
git config --global user.name "$PUBLISH_GIT_USERNAME (as ${{github.actor}})"
git config --global user.email "$PUBLISH_GIT_EMAIL"
git config --global gpg.format ssh
git config --global commit.gpgsign true
touch ~/.ssh/allowed_signers
echo "$(git config --get user.email) namespaces=\"git\" $(cat $PUBLISH_GIT_SIGN_KEY_PATH.pub)" >> ~/.ssh/allowed_signers
git config --global user.signingkey "$PUBLISH_GIT_SIGN_KEY_PATH"
- name: "Login to Docker Hub"
uses: docker/login-action@v3
with:
username: ${{secrets.PUBLISH_DOCKERHUB_USERNAME}}
password: ${{secrets.PUBLISH_DOCKERHUB_TOKEN}}
- name: "Fetch build artifacts"
uses: actions/download-artifact@v4
with:
path: "main/release"
- name: "Push release tag"
id: version
working-directory: "./main"
run: |
../mono/bin/mono publish --no-package-push --yes
export RELEASE_VERSION="$(script/read_version)"
echo "RELEASE_VERSION=$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
echo "TAG_NAME=v$RELEASE_VERSION" >> "$GITHUB_OUTPUT"
- name: "Create a release on the repository"
working-directory: "./main"
run: |
gh release create ${{steps.version.outputs.TAG_NAME}} \
--title "${{steps.version.outputs.RELEASE_VERSION}}" \
--notes-from-tag \
--verify-tag \
'release/x86_64-unknown-linux-gnu/x86_64-unknown-linux-gnu.tar.gz#Linux (x86_64)' \
'release/x86_64-unknown-linux-musl/x86_64-unknown-linux-musl.tar.gz#Linux (x86_64, musl)' \
'release/aarch64-unknown-linux-gnu/aarch64-unknown-linux-gnu.tar.gz#Linux (arm64)' \
'release/aarch64-unknown-linux-musl/aarch64-unknown-linux-musl.tar.gz#Linux (arm64, musl)' \
'release/x86_64-apple-darwin/x86_64-apple-darwin.tar.gz#macOS (x86_64)' \
'release/aarch64-apple-darwin/aarch64-apple-darwin.tar.gz#macOS (arm64)' \
'install.sh#Installer script'
env:
GH_TOKEN: ${{github.token}}