-
Notifications
You must be signed in to change notification settings - Fork 18
196 lines (170 loc) · 6.76 KB
/
release.yml
File metadata and controls
196 lines (170 loc) · 6.76 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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
name: Release new version
on:
push:
tags:
- '**'
permissions:
contents: write
jobs:
release-type:
name: Determine release type
runs-on: ubuntu-latest
outputs:
is-production: ${{ steps.set-var.outputs.is-production }}
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- name: Parse tag and branch
id: set-var
run: |
# Releases must be from the main branch and match a specific pattern.
if [[ $GITHUB_REF =~ ^refs/tags/[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
git fetch -q -n origin main
if ! git merge-base --is-ancestor "${GITHUB_SHA}" "origin/main"; then
echo "::error::Release for tag ${{ github.ref_name }} must be from a commit on the main branch."
exit 1
else
echo "is-production=true" >> $GITHUB_OUTPUT
fi
else
echo "is-production=false" >> $GITHUB_OUTPUT
fi
test-rules:
uses: './.github/workflows/test-rules.yaml'
test-docker-build:
uses: './.github/workflows/docker-build.yml'
integration-tests:
uses: './.github/workflows/integration-tests.yaml'
secrets: inherit
permissions:
contents: read
id-token: write
verify-schema:
uses: './.github/workflows/verify-schema.yaml'
versions-check:
uses: './.github/workflows/versions-check.yaml'
build:
needs:
- release-type
strategy:
fail-fast: false
matrix:
include:
- { target: aarch64-unknown-linux-gnu, os: ubuntu-latest, image: 'ubuntu:22.04' }
- { target: x86_64-unknown-linux-gnu, os: ubuntu-latest, image: 'ubuntu:22.04' }
- { target: aarch64-apple-darwin, os: macos-latest }
- { target: x86_64-apple-darwin, os: macos-15-intel }
- { target: x86_64-pc-windows-msvc, os: windows-latest }
name: Build binaries for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
container:
image: ${{ matrix.image || '' }}
options: --privileged
steps:
- name: Configure container
if: startsWith(matrix.os, 'ubuntu')
run: |
apt-get update
apt-get --no-install-recommends install -y build-essential ca-certificates curl git jq wget zip
git config --global --add safe.directory $GITHUB_WORKSPACE
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- uses: ./.github/actions/set-up-rust
with:
target: ${{ matrix.target }}
- name: Install cross-compilation tools
uses: taiki-e/setup-cross-toolchain-action@b8d1a322a6009a2b7220f53996695778eef89b41 # v1
with:
target: ${{ matrix.target }}
# Set the current SHA as the version so that it's exposed on the server.
- name: Set the version
shell: bash
run: sed "s/development/$GITHUB_SHA/g" crates/static-analysis-kernel/src/constants.rs > bla && rm crates/static-analysis-kernel/src/constants.rs && mv bla crates/static-analysis-kernel/src/constants.rs
- name: Fetch dependencies
run: cargo fetch
- name: Build Rust binaries
run: |
cargo build --locked --release --target ${{ matrix.target }} --bin datadog-static-analyzer
cargo build --locked --release --target ${{ matrix.target }} --bin datadog-static-analyzer-git-hook
cargo build --locked --release --target ${{ matrix.target }} --bin datadog-static-analyzer-server
- name: Zip Rust binaries (Unix)
if: ${{ !startsWith(matrix.os, 'windows') }}
run: |
zip -j datadog-static-analyzer-${{ matrix.target }}.zip target/${{ matrix.target }}/release/datadog-static-analyzer
zip -j datadog-static-analyzer-git-hook-${{ matrix.target }}.zip target/${{ matrix.target }}/release/datadog-static-analyzer-git-hook
zip -j datadog-static-analyzer-server-${{ matrix.target }}.zip target/${{ matrix.target }}/release/datadog-static-analyzer-server
- name: Zip Rust binaries (Windows)
if: startsWith(matrix.os, 'windows')
run: |
cd target\${{ matrix.target }}\release
7z a datadog-static-analyzer-${{ matrix.target }}.zip datadog-static-analyzer.exe
7z a datadog-static-analyzer-git-hook-${{ matrix.target }}.zip datadog-static-analyzer-git-hook.exe
7z a datadog-static-analyzer-server-${{ matrix.target }}.zip datadog-static-analyzer-server.exe
move *.zip ..\..\..\
- name: Upload assets
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: ${{ matrix.target }}
path: |
datadog-static-analyzer-${{ matrix.target }}.zip
datadog-static-analyzer-git-hook-${{ matrix.target }}.zip
datadog-static-analyzer-server-${{ matrix.target }}.zip
if-no-files-found: error
retention-days: 7
github-release:
name: Release on GitHub
needs:
- release-type
- test-rules
- test-docker-build
- integration-tests
- verify-schema
- versions-check
- build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout repository
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- name: Download build artifacts
uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4
with:
path: artifacts
- name: Display structure of downloaded files
run: ls -lR
working-directory: artifacts
- name: Create production release
if: ${{ needs.release-type.outputs.is-production == 'true' }}
run: |-
gh release create --generate-notes \
${{ github.ref_name }} \
versions.json \
artifacts/*/datadog-static-analyzer*.zip
env:
GH_TOKEN: ${{ github.token }}
- name: Create pre-release
if: ${{ needs.release-type.outputs.is-production != 'true' }}
run: |-
gh release create --generate-notes --prerelease \
${{ github.ref_name }} \
versions.json \
artifacts/*/datadog-static-analyzer*.zip
env:
GH_TOKEN: ${{ github.token }}
ghcr:
needs:
- release-type
- github-release
if: ${{ needs.release-type.outputs.is-production == 'true' }}
uses: './.github/workflows/ghcr.yml'
with:
is-production: ${{ needs.release-type.outputs.is-production == 'true' }}
permissions:
contents: read
packages: write
id-token: write