Skip to content

Commit da3efe8

Browse files
authored
Merge pull request #13 from zapta/main
Converted the build workflow to use the new apio workflow actions.
2 parents 9dc67de + 382a3e1 commit da3efe8

File tree

1 file changed

+42
-88
lines changed

1 file changed

+42
-88
lines changed

.github/workflows/build-and-release.yaml

Lines changed: 42 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -35,37 +35,22 @@ jobs:
3535
- name: Checkout this repo
3636
uses: actions/checkout@v4
3737

38-
- name: Install anti virus (ClamAV)
39-
run: |
40-
sudo apt-get update
41-
sudo apt-get install -y clamav clamav-daemon
42-
sudo systemctl stop clamav-freshclam || true
43-
sudo freshclam --verbose
44-
45-
# E.g. "2025-11-02"
46-
- name: Determine release tag
47-
run: |
48-
release_tag="$(date +'%Y-%m-%d')"
49-
echo ${release_tag}
50-
echo "RELEASE_TAG=${release_tag}" >> $GITHUB_ENV
51-
52-
# E.g. "20251102"
53-
- name: Determine package tag
54-
run: |
55-
package_tag="${RELEASE_TAG//-/}"
56-
echo $package_tag
57-
echo "PACKAGE_TAG=$package_tag" >> $GITHUB_ENV
38+
- name: Get release and package tags
39+
uses: fpgawars/apio-workflows/.github/actions/get-release-and-package-tags@main
40+
with:
41+
release-tag-var: RELEASE_TAG
42+
package-tag-var: PACKAGE_TAG
5843

59-
- name: Determine last commit
60-
run: |
61-
commit=$(git rev-parse HEAD)
62-
echo $commit
63-
echo "RELEASE_COMMIT=$commit" >> $GITHUB_ENV
44+
- name: Get repository commit
45+
uses: fpgawars/apio-workflows/.github/actions/get-repo-commit@main
46+
with:
47+
repo-dir: .
48+
env-var-name: RELEASE_COMMIT
6449

6550
- name: Determine package file name
6651
run: |
6752
package_name="apio-graphviz-windows-amd64-${PACKAGE_TAG}.tgz"
68-
echo $package_name
53+
echo "PACKAGE_NAME=$package_name"
6954
echo "PACKAGE_NAME=$package_name" >> $GITHUB_ENV
7055
7156
- name: Create the build info file
@@ -88,16 +73,15 @@ jobs:
8873
8974
cat -n build-info.json
9075
91-
- name: Format build info
92-
run: |
93-
npm install -g json-align
94-
json-align --in-place --spaces 2 build-info.json
95-
cat -n build-info.json
76+
- name: Format build info json file in-place
77+
uses: fpgawars/apio-workflows/.github/actions/format-json-file@main
78+
with:
79+
json-file: build-info.json
9680

9781
- name: Construct graphviz file name
9882
run: |
9983
graphviz_fname="windows_10_cmake_Release_Graphviz-${GRAPHVIZ_TAG}-win64.zip"
100-
echo ${graphviz_fname}
84+
echo "GRAPHVIZ_FNAME=${graphviz_fname}"
10185
echo "GRAPHVIZ_FNAME=${graphviz_fname}" >> $GITHUB_ENV
10286
10387
- name: Download graphviz file to _upstream
@@ -127,81 +111,51 @@ jobs:
127111
cp build-info.json _package/BUILD-INFO.json
128112
ls -al _package
129113
130-
# See https://en.wikipedia.org/wiki/EICAR_test_file
131-
# - name: Inject a virus scan test file
132-
# run: |
133-
# echo 'X5O!P%@AP[4\PZX54(P^)7CC)7}$EICAR-STANDARD-ANTIVIRUS-TEST-FILE!$H+H*' > _package/eicar.txt
134-
135114
- name: Compress the package
136115
run: |
137116
pushd _package
138117
tar zcf ../${PACKAGE_NAME} ./*
139118
popd
140119
ls -al
141120
121+
- name: Scan the package for viruses
122+
uses: fpgawars/apio-workflows/.github/actions/scan-files-for-viruses@main
123+
with:
124+
file-patterns: |
125+
apio-graphviz-*.tgz
126+
127+
- name: Convert json build info to text
128+
uses: fpgawars/apio-workflows/.github/actions/json-to-text@main
129+
with:
130+
input-json: build-info.json
131+
output-text: build-info.txt
132+
142133
- name: Prepare release text
143134
run: |
144-
cat > RELEASE_BODY.txt <<EOF
135+
cat > RELEASE-BODY.txt <<EOF
145136
This is an automated build-and-release.
146137
147138
Build info:
148139
\`\`\`
149-
$(tr -d '",{}' < build-info.json)
140+
$(cat build-info.txt)
150141
\`\`\`
151142
EOF
152143
153-
cat -n $out
144+
cat -n RELEASE-BODY.txt
145+
146+
- name: Cleanup old pre-releases
147+
uses: fpgawars/apio-workflows/.github/actions/cleanup-old-prereleases@main
154148

155-
# Delete old pre-releases, keeps all releases.
156-
- name: Delete old pre-releases
157-
uses: sgpublic/delete-release-action@v1.2
149+
- name: Ensure no conflicting release
150+
uses: fpgawars/apio-workflows/.github/actions/ensure-no-conflicting-release@main
158151
with:
159-
# Keep all stable releases .
160-
release-drop: false
161-
# Delete old pre-releases, keep the newest 10 (excluding the absolute latest)
162-
pre-release-drop: true
163-
pre-release-keep-count: 5
164-
pre-release-drop-tag: true # Also delete tags of deleted pre-releases
165-
# Keep all drafts.
166-
draft-drop: false
167-
env:
168-
GITHUB_TOKEN: ${{ github.token }}
169-
170-
# Scans recursively inside the .tgz packages.
171-
# See https://linux.die.net/man/1/clamscan
172-
- name: Scan the package for viruses
173-
run: |
174-
clamscan -r --verbose --scan-archive=yes apio-graphviz-*.tgz
152+
release-tag: ${{ env.RELEASE_TAG }}
175153

176-
- name: Delete same tag pre-release if exist.
177-
run: |
178-
set -e
179-
gh release list --limit 100
180-
output=$(gh release view "$RELEASE_TAG" --json name,tagName,isDraft,isImmutable,isPrerelease 2>&1 || true)
181-
echo $output
182-
if [[ "$output" == "release not found" ]]; then
183-
echo "Release $RELEASE_TAG does not exist, safe to continue."
184-
elif [[ "$(echo "$output" | jq -r '.isPrerelease')" == "true" ]]; then
185-
echo "Release $RELEASE_TAG exists and is a pre-release, deleting."
186-
gh release delete "$RELEASE_TAG" --yes --cleanup-tag
187-
elif [[ "$(echo "$output" | jq -r '.isPrerelease')" == "false" ]]; then
188-
echo "Error: A stable release (non pre-release) already exists for tag $RELEASE_TAG."
189-
exit 1
190-
else
191-
echo "Error determining if release $RELEASE_TAG exists"
192-
exit 1
193-
fi
194-
env:
195-
GITHUB_TOKEN: ${{ github.token }}
196-
197-
- name: Create the Release and upload files
198-
uses: softprops/action-gh-release@v2.2.2
154+
- name: Create GitHub pre-release
155+
uses: fpgawars/apio-workflows/.github/actions/create-pre-release@main
199156
with:
200-
tag_name: ${{env.RELEASE_TAG}}
201-
name: ${{env.RELEASE_TAG}}
202-
body_path: RELEASE_BODY.txt
203-
preserve_order: true
204-
prerelease: true
205-
fail_on_unmatched_files: true
157+
release_tag: ${{ env.RELEASE_TAG }}
158+
body_path: RELEASE-BODY.txt
159+
# We intensionally list explicitly all the expected files.
206160
files: |
207161
apio-graphviz-windows-amd64-${{env.PACKAGE_TAG}}.tgz

0 commit comments

Comments
 (0)