Repository navigation
149 lines (129 loc) · 4.67 KB
/
Copy pathbuild-release.yml
File metadata and controls
149 lines (129 loc) · 4.67 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
name: Build data bundle
on:
push:
branches:
- master
paths:
- ".github/workflows/build-release.yml"
- "requirements*.txt"
- "scripts/**"
# Carried map assets change the bundle, so a push touching them must rebuild.
- "maps/**"
- "banner/**"
- "THIRD_PARTY_NOTICES.md"
workflow_dispatch:
inputs:
release_mode:
description: What to do after the bundle passes validation
required: true
default: draft
type: choice
options:
- validate
- draft
- publish
schedule:
- cron: "20 16 * * 1"
permissions:
contents: write
concurrency:
group: data-bundle-release
cancel-in-progress: false
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 90
env:
RELEASE_MODE: ${{ github.event_name == 'schedule' && 'publish' || github.event_name == 'workflow_dispatch' && inputs.release_mode || 'validate' }}
steps:
- name: Check out builder
uses: actions/checkout@11d5960a326750d5838078e36cf38b85af677262 # v4
- name: Set up Python
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.13"
cache: pip
- name: Install dependencies
run: python -m pip install --disable-pip-version-check -r requirements-dev.txt
- name: Check Python sources
run: |
ruff check scripts
ruff format --check scripts
python -m compileall -q scripts
- name: Build Data.zip
run: python scripts/build_data.py
- name: Validate Data.zip independently
run: python scripts/validate_archive.py build/release/Data.zip
- name: Retain validated bundle
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: RatScannerData
path: build/release/*
if-no-files-found: error
retention-days: 14
- name: Detect changed content
id: content
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
content_sha="$(jq -r '.contentSha256' build/release/manifest.json)"
echo "sha=${content_sha}" >> "$GITHUB_OUTPUT"
mkdir -p build/previous
if gh release download --repo "$GITHUB_REPOSITORY" \
--pattern manifest.json --dir build/previous 2>/dev/null; then
previous_sha="$(jq -r '.contentSha256' build/previous/manifest.json)"
else
previous_sha=""
fi
if [[ -n "$previous_sha" && "$previous_sha" == "$content_sha" ]]; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "Bundle content is unchanged."
else
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "Bundle content changed: ${previous_sha:-none} -> ${content_sha}"
fi
- name: Create release
if: steps.content.outputs.changed == 'true' && env.RELEASE_MODE != 'validate'
env:
GH_TOKEN: ${{ github.token }}
shell: bash
run: |
set -euo pipefail
# Releases are named for the day they were cut, matching the history this
# repository used before the bundle was automated. At most one release is
# drafted per day, so the date is unique and doubles as the tag.
tag="$(date -u +%Y%m%d)"
title="$tag"
if existing_draft="$(gh release view "$tag" --repo "$GITHUB_REPOSITORY" \
--json isDraft --jq '.isDraft' 2>/dev/null)"; then
if [[ "$RELEASE_MODE" == "publish" && "$existing_draft" == "true" ]]; then
gh release edit "$tag" --repo "$GITHUB_REPOSITORY" \
--draft=false --latest
echo "Published existing validated draft ${tag}."
else
echo "Release ${tag} already exists."
fi
exit 0
fi
notes="Automated RatScanner runtime data bundle.
Sources and checksums are recorded in manifest.json. Item images are
third-party, game-derived assets obtained through tarkov.dev for
item-recognition compatibility. See THIRD_PARTY_NOTICES.md."
args=(
release create "$tag"
build/release/Data.zip
build/release/Data.zip.sha256
build/release/manifest.json
--repo "$GITHUB_REPOSITORY"
--target "$GITHUB_SHA"
--title "$title"
--notes "$notes"
)
if [[ "$RELEASE_MODE" == "draft" ]]; then
args+=(--draft)
else
args+=(--latest)
fi
gh "${args[@]}"