Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
Changed publish options
Browse files Browse the repository at this point in the history
- also moved py scripts out
- improved readibility
  • Loading branch information
clicketyclackety committed Mar 25, 2023
1 parent 6e047b8 commit 90808ba
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 36 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ steps:
with:
package-name: 'My Yak Package'
token: ${{ secrets.YAK_TOKEN }}
build-path: 'src/project/bin/**/x64/'
build-path: 'src/**/bin/**/**/'
publish: 'test'
platform: win
```
Expand All @@ -34,8 +35,8 @@ steps:
with:
package-name: 'My Yak Package'
token: ${{ secrets.YAK_TOKEN }}
build-path: 'src/project/bin/**/x64/''
test-run: false
build-path: 'src/project/bin/**/x64/'
publish: 'production'
platform: ${{ matrix.os }}
```
Expand All @@ -46,7 +47,7 @@ steps:
| `package-name` | The name of the package | Enclose in quotes if spaces exist |
| `token` | `${{ secrets.YAK_TOKEN }}` | Use yak.exe --ci locally to get this token. Add to GitHub secrets. |
| `build-path` | | globs accepted |
| `test-run` | true or false | test-run uploads to the McNeel Test Server |
| `publish` | '', 'test', 'production' | '' publishes nothing, 'test' published to the the McNeel Test Server. 'production' published to the real yak package server |
| `platform` | windows/win or mac/mac-os | Linux not supported |


Expand Down
49 changes: 17 additions & 32 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ inputs:
build-path:
description: 'The Build Directory for the Package'
required: true
test-run:
description: 'Publish to the test server'
publish:
description: 'Publish'
required: false
default: true
default: ''
platform:
description: 'The Platform for the Package'
required: false
Expand All @@ -25,7 +25,7 @@ branding:
outputs:
result:
description: 'Was the upload succesful?'
value: true # ${{ steps.random-number-generator.outputs.random-number }}
value: true
runs:
using: "composite"
steps:
Expand All @@ -35,43 +35,28 @@ runs:
run : |
pip install wget
- name: Move to yak package directory
shell: python
run: |
cd ${{ inputs.build-path }}
- name: Cache Yak
id: cache-yak
uses: actions/cache@v3
with:
path: 'yak.exe'
key: yak-exe

# https://discourse.mcneel.com/t/github-action-to-yak/120815/2
- name: Download Yak
shell: python
run: |
import wget
url = "http://files.mcneel.com/yak/tools/latest/yak.exe"
wget.download(url, "yak.exe")
shell: null
if: steps.cache-yak.outputs.cache-hit != 'true'
run: python3 py/download-yak.py

- name : Enable Yak exe on Unix
if: runner.os != 'Windows'
shell: bash
run: chmod +x yak.exe

- name: Build Package(s)
shell: python
run: |
import subprocess as proc
platform = ${{ inputs.platform }}
platform = platform[:3]
proc.run( [ 'yak.exe', 'build', '--platform', platform ] )
shell: null
run: python3 py/build-package.py

- name : Upload Yak(s)
shell: python
run: |
import subprocess as proc
from glob import glob
source="https://yak.rhino3d.com"
if ${{ inputs.test-run }}:
source="https://test.yak.rhino3d.com"
for yakPackage in glob('.\*yak'):
proc.run( [ 'yak.exe', 'push', yakPackage, '--source', source ] )
shell: null
run: python3 py/upload-yak.py -p inputs.publish -b inputs.buildpath
28 changes: 28 additions & 0 deletions py/build-package.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import subprocess as proc
import argparse
import os
import sys

parser = argparse.ArgumentParser()
parser.add_argument("-p", "--platform", type=str, default='any', choices=['win', 'mac', 'any'])
parser.add_argument("-b", "--buildpath", type=str, required=True)

args = parser.parse_args()

platform = args.platform[:3].lower()

cwd = os.getcwd()
yak_exe_path = f'{cwd}\yak.exe'


os.chdir(args.buildpath)
print(f'moved to {os.getcwd()}')

try:
result = proc.run( [ yak_exe_path, 'build', '--platform', platform ] )
if (result.returncode == 1):
print ('yak failed to build')
finally:
os.chdir(cwd)

sys.exit(result.returncode)
18 changes: 18 additions & 0 deletions py/download-yak.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import sys
import os

if os.path.isfile('yak.exe'):
print('Yak is already downloaded. Using Cached version')
sys.exit(0)

try:
import wget
url = 'http://files.mcneel.com/yak/tools/latest/yak.exe'
wget.download(url, 'yak.exe')

sys.exit(0)

except:
import sys
print ('failed to download yak from McNeel Servers')
sys.exit(1)
35 changes: 35 additions & 0 deletions py/upload-yak.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import subprocess as proc
from glob import glob
import argparse
import os
import sys

parser = argparse.ArgumentParser()
parser.add_argument("-p", "--publish", type=str, default=' ', choices=[None, 'test', 'production'])
parser.add_argument("-b", "--buildpath", type=str, required=True)

args = parser.parse_args()

source = None
if args.publish == 'test':
source="https://test.yak.rhino3d.com"
if args.publish == 'production':
source="https://yak.rhino3d.com"

if source == None:
print ('Publish is None, exiting.')
sys.exit(0)

cwd = os.getcwd()
yak_exe_path = f'{cwd}\yak.exe'

yakPackages = glob(f'{args.buildpath}\*.yak')
if yakPackages:
for yakPackage in yakPackages:
proc.run( [ yak_exe_path, 'push', yakPackage, '--source', source ] )
print (f'Published package {yakPackage} successfully to {source}')
else:
print (f'No Yak Packages found for given build path {args.buildpath}')
sys.exit(1)

sys.exit(0)
Binary file added py/yak.exe
Binary file not shown.

0 comments on commit 90808ba

Please sign in to comment.