Skip to content

Commit

Permalink
Skip compression if archive already exists
Browse files Browse the repository at this point in the history
  • Loading branch information
TheVeryDarkness committed Oct 29, 2023
1 parent afa2a92 commit d1209bd
Showing 1 changed file with 55 additions and 28 deletions.
83 changes: 55 additions & 28 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,42 +149,69 @@ jobs:
releaseName: ${{ env.Z3_VERSION }}
- uses: actions/setup-python@v4
with:
python-version: '3.10'
python-version: "3.10"
- name: Compress built z3.
continue-on-error: true
shell: python
id: compress_z3
working-directory: ${{ github.workspace }}
run: |
from shutil import make_archive, copyfile
from os import mkdir, listdir
from os import mkdir, listdir, environ
from pathlib import Path
HEADERS = [
"z3++.h", "z3.h", "z3_algebraic.h", "z3_api.h", "z3_ast_containers.h", "z3_fixedpoint.h", "z3_fpa.h", "z3_macros.h", "z3_optimization.h", "z3_polynomial.h", "z3_rcf.h", "z3_spacer.h", "z3_v1.h", "z3_version.h"
]
FROM = Path(r"${{ env.VCPKG_ROOT }}/installed/${{ matrix.vcpkg_triplet }}")
TO = Path(r"${{ github.workspace }}/${{ matrix.vcpkg_triplet }}")
LIB = Path(r"${{ matrix.lib }}")
print("`include` dir:", listdir(FROM / "include"))
print("`lib` dir:", listdir(FROM / "lib"))
mkdir(TO)
copyfile(FROM / "lib" / LIB, TO / LIB)
for header in HEADERS:
copyfile(FROM / "include/" / header, TO / header)
make_archive(
base_name=r"${{ matrix.vcpkg_triplet }}",
format="gztar",
root_dir=".",
base_dir=r"${{ matrix.vcpkg_triplet }}",
verbose=True,
)
print("workspace:", listdir(r"${{ github.workspace }}"))
from json import loads
def main():
ASSETS_STRING = r"""
${{ steps.get_release.outputs.assets }}
"""
ASSETS: list[dict] = loads(ASSETS_STRING)
found: bool = False
for asset in ASSETS:
if 'name' in asset and asset['name'] == r"${{ matrix.vcpkg_triplet }}.tar.gz":
found = True
break
if "GITHUB_OUTPUT" in environ:
OUT = environ["GITHUB_OUTPUT"]
with open(OUT, "a") as o:
o.write(f"FOUND={int(found)}\n")
else:
print("$GITHUB_OUTPUT not found.")
if found:
print("Archive already uploaded, skipping.")
return
HEADERS = [
"z3++.h", "z3.h", "z3_algebraic.h", "z3_api.h", "z3_ast_containers.h", "z3_fixedpoint.h", "z3_fpa.h", "z3_macros.h", "z3_optimization.h", "z3_polynomial.h", "z3_rcf.h", "z3_spacer.h", "z3_v1.h", "z3_version.h"
]
FROM = Path(
r"${{ env.VCPKG_ROOT }}/installed/${{ matrix.vcpkg_triplet }}")
TO = Path(r"${{ github.workspace }}/${{ matrix.vcpkg_triplet }}")
LIB = Path(r"${{ matrix.lib }}")
print("`include` dir:", listdir(FROM / "include"))
print("`lib` dir:", listdir(FROM / "lib"))
mkdir(TO)
copyfile(FROM / "lib" / LIB, TO / LIB)
for header in HEADERS:
copyfile(FROM / "include/" / header, TO / header)
make_archive(
base_name=r"${{ matrix.vcpkg_triplet }}",
format="gztar",
root_dir=".",
base_dir=r"${{ matrix.vcpkg_triplet }}",
verbose=True,
)
print("workspace:", listdir(r"${{ github.workspace }}"))
main()
- name: Upload built z3.
continue-on-error: true
uses: actions/upload-release-asset@v1
if: ${{ !steps.compress_z3.outputs.found }}
env:
GITHUB_TOKEN: ${{ github.token }}
with:
Expand Down

0 comments on commit d1209bd

Please sign in to comment.