Skip to content

Commit

Permalink
ci: Make and add cvc5 packages (cvc5#10250)
Browse files Browse the repository at this point in the history
This PR creates and stores shared/static packages for each platform to
latest and release.
  • Loading branch information
daniel-larraz authored Jan 9, 2024
1 parent 34da08f commit 8173a9f
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,33 +1,50 @@
name: Store binary
description: Store cvc5 binary to the latest tag or the current release
name: Add package
description: Create a package and store it to the latest tag or the current release
inputs:
binary:
description: file name of binary
binary-name:
description: target name of binary
build-dir:
description: path to the build directory
package-name:
description: target name of the package
github-token-latest:
description: token to upload binary to latest
description: token to upload package to latest
github-token-release:
description: token to upload binary to release
description: token to upload package to release
runs:
using: composite
steps:
- name: Rename binary
- name: Create ZIP file
shell: bash
run: |
cp ${{ inputs.binary }} ${{ inputs.binary-name }}
echo "::group::Create ZIP file"
# Run 'make install' on build directory
pushd ${{ inputs.build-dir }}
make install
popd
# Copy COPYING file to install directory
cp COPYING ${{ inputs.build-dir }}/install/
# Create ZIP file
pushd ${{ inputs.build-dir }}
mv install ${{ inputs.package-name }}
zip -r ${{ inputs.package-name }} ${{ inputs.package-name }}
popd
# Move package to root directory
mv ${{ inputs.build-dir }}/${{ inputs.package-name }}.zip .
echo "::endgroup::"
- name: install pyGithub
shell: bash
run: |
python3 -m pip install pyGithub
- name: store to latest
- name: Store to latest
if: github.ref == 'refs/heads/main'
shell: 'python3 {0}'
env:
GITHUB_TOKEN: ${{ inputs.github-token-latest }}
BINARY: ${{ inputs.binary-name }}
PACKAGE: ${{ inputs.package-name }}.zip
run: |
import datetime
import os
Expand All @@ -54,8 +71,8 @@ runs:
rel = repo.create_git_release('latest', 'latest', 'Latest builds')
# generate new filename
binary = os.getenv('BINARY')
name,ext = os.path.splitext(binary)
package = os.getenv('PACKAGE')
name,ext = os.path.splitext(package)
curtime = repo.get_git_commit(sha).committer.date.strftime('%Y-%m-%d')
samedayprefix = '{}-{}-'.format(name, curtime)
filename = '{}-{}-{}{}'.format(name, curtime, sha[:7], ext)
Expand All @@ -66,7 +83,7 @@ runs:
for cnt,asset in enumerate(assets):
delete = False
if cnt >= 30:
if cnt >= 32:
delete = True
if asset.name.startswith(samedayprefix):
delete = True
Expand All @@ -78,14 +95,14 @@ runs:
asset.delete_asset()
# upload as asset with proper name
rel.upload_asset(binary, name=filename)
rel.upload_asset(package, name=filename)
- name: store to release
- name: Store to release
if: startsWith(github.ref, 'refs/tags/')
shell: 'python3 {0}'
env:
GITHUB_TOKEN: ${{ inputs.github-token-release }}
BINARY: ${{ inputs.binary-name }}
PACKAGE: ${{ inputs.package-name }}.zip
run: |
import os
from github import Github
Expand All @@ -100,5 +117,4 @@ runs:
ref = repo.get_git_ref('tags/' + refname)
commit = repo.get_git_commit(ref.object.sha)
rel = repo.create_git_release(refname, refname, commit.message)
rel.upload_asset(os.getenv('BINARY'))
rel.upload_asset(os.getenv('PACKAGE'))
29 changes: 19 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
python-bindings: true
build-documentation: true
check-examples: true
binary-name: cvc5-Linux
package-name: cvc5-Linux
exclude_regress: 3-4
run_regression_args: --tester base --tester model --tester synth --tester abduct --tester dump

Expand All @@ -31,7 +31,7 @@ jobs:
strip-bin: strip
python-bindings: false # Temporarily disabling checking of python bindings on MacOS.
check-examples: true
binary-name: cvc5-macOS
package-name: cvc5-macOS
exclude_regress: 3-4
run_regression_args: --tester base --tester model --tester synth --tester abduct --tester dump

Expand All @@ -42,16 +42,15 @@ jobs:
cache-key: production-arm64
strip-bin: strip
python-bindings: false # Temporarily disabling checking of python bindings on MacOS.
binary-name: cvc5-macOS-arm64
package-name: cvc5-macOS-arm64

- name: win64:production
os: ubuntu-latest
config: production --auto-download --win64
cache-key: productionwin64
strip-bin: x86_64-w64-mingw32-strip
windows-build: true
binary-name: cvc5-Win64.exe
binary-ext: .exe
package-name: cvc5-Win64

- name: ubuntu:production-clang
os: ubuntu-latest
Expand Down Expand Up @@ -142,12 +141,22 @@ jobs:
with:
build-dir: ${{ steps.configure-and-build.outputs.shared-build-dir }}

- name: Add binary to latest and release
if: matrix.binary-name && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
uses: ./.github/actions/store-binary
- name: Create and add shared package to latest and release
if: matrix.package-name && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
uses: ./.github/actions/add-package
with:
binary: ${{ steps.configure-and-build.outputs.static-build-dir }}/bin/cvc5${{ matrix.binary-ext }}
binary-name: ${{ matrix.binary-name }}
build-dir: ${{ steps.configure-and-build.outputs.shared-build-dir }}
package-name: ${{ matrix.package-name }}-shared
# when using GITHUB_TOKEN, no further workflows are triggered
github-token-latest: ${{ secrets.GITHUB_TOKEN }}
github-token-release: ${{ secrets.ACTION_USER_TOKEN }}

- name: Create and add static package to latest and release
if: matrix.package-name && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/'))
uses: ./.github/actions/add-package
with:
build-dir: ${{ steps.configure-and-build.outputs.static-build-dir }}
package-name: ${{ matrix.package-name }}-static
# when using GITHUB_TOKEN, no further workflows are triggered
github-token-latest: ${{ secrets.GITHUB_TOKEN }}
github-token-release: ${{ secrets.ACTION_USER_TOKEN }}
Expand Down

0 comments on commit 8173a9f

Please sign in to comment.