Skip to content

build-and-release

build-and-release #5

# Daily build and release workflow.
name: build-and-release
on:
# Run on each commit to this repo.
push:
# Run daily at 10AM UTC
schedule:
- cron: "0 10 * * *"
# Allow manual activations.
workflow_dispatch:
permissions:
# Allow release creation
contents: write
env:
# -- Set the version of the upstream release.
# -- See list at https://graphviz.gitlab.io/download/
GRAPHVIZ_TAG: 12.1.2
jobs:
# -- Build packages for all supported architectures and
# -- export them in a release.
build-and-release:
runs-on: ubuntu-22.04
steps:
# Check out the this repo in the workflow work directory.
- name: Checkout this repo
uses: actions/checkout@v4
# E.g. "2025-11-02"
- name: Determine release tag
run: |
release_tag="$(date +'%Y-%m-%d')"
echo ${release_tag}
echo "RELEASE_TAG=${release_tag}" >> $GITHUB_ENV
# E.g. "20251102"
- name: Determine package tag
run: |
package_tag="${RELEASE_TAG//-/}"
echo $package_tag
echo "PACKAGE_TAG=$package_tag" >> $GITHUB_ENV
- name: Determine last commit
run: |
commit=$(git rev-parse HEAD)
echo $commit
echo "RELEASE_COMMIT=$commit" >> $GITHUB_ENV
- name: Determine package file name
run: |
package_name="apio-graphviz-windows-amd64-${PACKAGE_TAG}.tgz"
echo $package_name
echo "PACKAGE_NAME=$package_name" >> $GITHUB_ENV
- name: Create the build info file
run: |
cat > build-info.json <<EOF
{
"package-name": "graphviz",
"description" : "Graphviz tools for Apio",
"target-platform": "windows-amd64",
"release-tag": "${RELEASE_TAG}",
"build-repo": "${{github.repository}}",
"build-workflow": "${{ github.workflow }}",
"workflow-run-id": "${{github.run_id}}",
"workflow-run-number": "${{github.run_number}}",
"build-time": "$(date +'%Y-%m-%d %H:%M:%S %Z')",
"commit": "$RELEASE_COMMIT",
"file-name": "$PACKAGE_NAME"
}
EOF
cat -n build-info.json
- name: Format build info
run: |
npm install -g json-align
json-align --in-place --spaces 2 build-info.json
cat -n build-info.json
- name: Construct graphviz file name
run: |
graphviz_fname="windows_10_cmake_Release_Graphviz-${GRAPHVIZ_TAG}-win64.zip"
echo ${graphviz_fname}
echo "GRAPHVIZ_FNAME=${graphviz_fname}" >> $GITHUB_ENV
- name: Download graphviz file to _upstream
run: |
url="https://gitlab.com/api/v4/projects/4207231/packages/generic/graphviz-releases/${GRAPHVIZ_TAG}/${GRAPHVIZ_FNAME}"
echo $url
mkdir _upstream
pushd _upstream
wget -nv $url
popd
find _upstream
- name: Uncompress the graphviz file
run: |
pushd _upstream
unzip ${GRAPHVIZ_FNAME}
popd
find _upstream
- name: Move upstream package to _package
run: |
mv _upstream/Graphviz-${GRAPHVIZ_TAG}-win64 _package
ls -al _package
- name: Copy build info file to _package
run: |
cp build-info.json _package/BUILD-INFO.json
ls -al _package
- name: Compress the package
run: |
pushd _package
tar zcf ../${PACKAGE_NAME} ./*
popd
ls -al
- name: Prepare release text
run: |
cat > RELEASE_BODY.txt <<EOF
This is an automated build-and-release.
Build info:
\`\`\`
$(tr -d '",{}' < build-info.json)
\`\`\`
EOF
cat -n $out
# In case we overwrite and exiting release.
- name: Force tag update
run: |
git tag -f ${{env.RELEASE_TAG}}
git push origin -f ${{env.RELEASE_TAG}}
- name: Create the Release and upload files
uses: softprops/[email protected]
with:
tag_name: ${{env.RELEASE_TAG}}
name: ${{env.RELEASE_TAG}}
body_path: RELEASE_BODY.txt
preserve_order: true
fail_on_unmatched_files: true
files: |
apio-graphviz-windows-amd64-${{env.PACKAGE_TAG}}.tgz