Skip to content

Commit

Permalink
Release creation (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
mfherbst authored Dec 8, 2020
1 parent 2fe0e99 commit f0637fc
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 17 deletions.
76 changes: 60 additions & 16 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ name: CI

on: [push]

env:
BUILD_TYPE: Release

jobs:
build:
runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -33,24 +30,71 @@ jobs:
${{ runner.os }}-deploy-
${{ runner.os }}-
- name: Create Build Environment
run: cmake -E make_directory ${{runner.workspace}}/build

- name: Configure CMake
- name: Build
shell: bash
working-directory: ${{runner.workspace}}/build
run: |
export PATH="/usr/local/opt/ccache/libexec:$PATH"
export PATH="/usr/lib/ccache:$PATH"
cmake $GITHUB_WORKSPACE -GNinja -DCMAKE_BUILD_TYPE=$BUILD_TYPE
ccache --max-size 2G
./build_libtensor.py -v -d ${{runner.workspace}}/build --install ${{runner.workspace}}/install --type Release
- name: Build
- name: Test
working-directory: ${{runner.workspace}}/build
shell: bash
run: cmake --build . --config $BUILD_TYPE
run: ctest --output-on-failure

- name: Test
working-directory: ${{runner.workspace}}/build
- name: Bundle tarball
shell: bash
run: ctest -C $BUILD_TYPE
run: |
./scripts/pack_release.py ${{runner.workspace}}/install
- name: Upload tarball as artefact
uses: actions/upload-artifact@v2
with:
name: libtensorlight-${{ matrix.os }}
path: libtensorlight-*.tar.gz

release:
if: startsWith(github.ref, 'refs/tags')
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v2
with:
path: artifacts
- name: Glob asset paths
id: asset_paths
run: |
LINUX_PATH=$(ls artifacts/*/*.tar.gz | grep -i linux | head -n 1)
LINUX_NAME=$(basename "$LINUX_PATH")
MACOS_PATH=$(ls artifacts/*/*.tar.gz | grep -i macos | head -n 1)
MACOS_NAME=$(basename "$MACOS_PATH")
RELEASE_NAME=v$(echo "$LINUX_NAME" | cut -d- -f2)
echo "::set-output name=linux_path::$LINUX_PATH"
echo "::set-output name=macos_path::$MACOS_PATH"
echo "::set-output name=linux_name::$LINUX_NAME"
echo "::set-output name=macos_name::$MACOS_NAME"
echo "::set-output name=release_name::$RELEASE_NAME"
- uses: actions/create-release@v1
id: create_release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ steps.asset_paths.outputs.release_name }}
draft: true
prerelease: false
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.asset_paths.outputs.linux_path }}
asset_name: ${{ steps.asset_paths.outputs.linux_name }}
asset_content_type: application/x-gtar
- uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ${{ steps.asset_paths.outputs.macos_path }}
asset_name: ${{ steps.asset_paths.outputs.macos_name }}
asset_content_type: application/x-gtar
2 changes: 1 addition & 1 deletion .github/workflows/deploy_conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Install deps on macos
if: contains( matrix.os, 'macos')
run: brew install coreutils || true

- name: Install macOS SDK
if: contains( matrix.os, 'macos')
working-directory: /Users/runner
Expand Down
35 changes: 35 additions & 0 deletions scripts/pack_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env python3
import os
import re
import sys
import subprocess
import configparser
import distutils.util

if not os.path.isfile("scripts/pack_release.py"):
raise RuntimeError("Please run from top dir of repository")

if len(sys.argv) != 2:
raise RuntimeError("Usage: scripts/pack_release.py install_dir")

install_dir = sys.argv[1]
if not os.path.isdir(install_dir):
raise RuntimeError(f"Install directory {install_dir} does not exist")

platform = distutils.util.get_platform().replace('.', '_').replace('-', '_')

# Get current libtensorlight version
config = configparser.RawConfigParser()
config.read("setup.cfg")
ltl_version = config.get("bumpversion", "current_version")

# Check if this points to a tag
git_revision = subprocess.check_output(["git", "rev-parse", "HEAD"],
universal_newlines=True).strip()
git_tag = subprocess.check_output(["git", "tag", "--points-at", git_revision],
universal_newlines=True).strip()
if not re.match("^v([0-9.]+)$", git_tag):
ltl_version = ltl_version + ".dev"

filename = f"libtensorlight-{ltl_version}-{platform}.tar.gz"
subprocess.check_call(["tar", "-C", install_dir, "-czf", filename, "include", "lib"])

0 comments on commit f0637fc

Please sign in to comment.