-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (68 loc) · 2.51 KB
/
Copy pathbuild.yml
File metadata and controls
82 lines (68 loc) · 2.51 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
name: "Build"
on:
push:
branches: ["main"]
pull_request:
types:
- "opened"
- "reopened"
- "synchronize"
workflow_dispatch:
defaults:
run:
shell: "bash"
jobs:
build:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout repository"
uses: "actions/checkout@v6"
with:
persist-credentials: false
- name: "Setup Go environment"
uses: "actions/setup-go@v6"
with:
go-version: "1.26"
- name: "Build binaries"
run: "go tool task all"
- name: "Run tests"
run: "go tool task test"
- name: "Setup env"
run: |
ts="$(TZ=UTC date '+%Y%m%d-%H%M%S')"
{
echo "timestamp=$ts"
if [ "${{ github.event_name }}" = "pull_request" ]; then
echo "snapshot_path=pull-request/${ts}-run-${{ github.run_id }}-pr-${{ github.event.number }}"
else
echo "snapshot_path=$BRANCH_NAME/${ts}-run-${{ github.run_id }}"
fi
} | tee -a "$GITHUB_ENV"
env:
# See: https://docs.github.com/en/actions/reference/security/secure-use#good-practices-for-mitigating-script-injection-attacks
BRANCH_NAME: "${{ github.head_ref || github.ref_name }}"
- name: "Setup nFPM"
env:
GH_TOKEN: "${{ github.token }}"
run: |
gh release download --repo goreleaser/nfpm -p "*amd64.deb" -O nfpm.deb
sudo apt-get install -y ./nfpm.deb
- name: "Build packages"
env:
TIMESTAMP: "${{ env.timestamp }}"
run: "nfpm package -f dist/linux/nfpm.yaml -p deb -t target/"
- name: "Upload build artifacts to S3"
env:
AWS_DEFAULT_REGION: "eu-west-1"
AWS_ACCESS_KEY_ID: "${{ secrets.AWS_S3_SNAPSHOTS_ACCESS_KEY_ID }}"
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_S3_SNAPSHOTS_SECRET_ACCESS_KEY }}
AWS_S3_BUCKET: "${{ secrets.AWS_S3_SNAPSHOTS_BUCKET }}"
TIMESTAMP: "${{ env.timestamp }}"
SNAPSHOT_PATH: "${{ env.snapshot_path }}"
working-directory: "target"
run: |
printf -- "## Artifacts\n\n" >> "$GITHUB_STEP_SUMMARY"
for file in $(find . -maxdepth 1 -name 'graylog-collector*' -type f | sort -V); do
aws s3 cp --no-progress "$file" "s3://${AWS_S3_BUCKET}/collector/${SNAPSHOT_PATH}/"
printf -- "- https://downloads.graylog.org/snapshots/collector/%s/%s\n" "$SNAPSHOT_PATH" "$(basename "$file")" >> "$GITHUB_STEP_SUMMARY"
done