Skip to content

Commit

Permalink
Combine the artifacts for easier downloading (#2)
Browse files Browse the repository at this point in the history
Rewrite the main workflow so the artifact it creates is useful
  • Loading branch information
tbttfox authored Aug 22, 2023
1 parent 2bd94c4 commit eb6effa
Show file tree
Hide file tree
Showing 3 changed files with 107 additions and 81 deletions.
96 changes: 60 additions & 36 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: build

on:
push:
branches: [ main ]
tags:
- v*
pull_request:
Expand Down Expand Up @@ -55,14 +54,17 @@ jobs:

- name: Repath Artifacts
run: |
mkdir artifacts/plug-ins
Copy-Item "./build/${{env.BUILD_TYPE}}/blurPostDeform.mll" -Destination "artifacts/plug-ins"
mkdir artifacts/blurdeform/win64-${{matrix.maya}}/plug-ins
Copy-Item "./build/${{env.BUILD_TYPE}}/blurPostDeform.mll" -Destination "artifacts/blurdeform/win64-${{matrix.maya}}/plug-ins"
New-Item -Name artifacts/blurdeform.mod -ItemType File
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: windows-${{matrix.maya}}
path: artifacts/plug-ins/blurPostDeform.mll
name: blurdeform
path: |
artifacts/blurdeform/win64-${{matrix.maya}}/plug-ins/blurPostDeform.mll
artifacts/blurdeform.mod
maya-macos:
runs-on: macos-latest
Expand Down Expand Up @@ -107,14 +109,18 @@ jobs:

- name: Repath Artifacts
run: |
mkdir -p artifacts/plug-ins
cp ./build/${{env.BUILD_TYPE}}/blurPostDeform.bundle artifacts/plug-ins
mkdir -p artifacts/blurdeform/mac-${{matrix.maya}}/plug-ins
cp ./build/${{env.BUILD_TYPE}}/blurPostDeform.bundle artifacts/blurdeform/mac-${{matrix.maya}}/plug-ins
touch artifacts/blurdeform.mod
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: mac-${{matrix.maya}}
path: artifacts/plug-ins/blurPostDeform.bundle
name: blurdeform
path: |
artifacts/blurdeform/mac-${{matrix.maya}}/plug-ins/blurPostDeform.bundle
artifacts/blurdeform.mod
maya-linux:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -154,14 +160,50 @@ jobs:

- name: Repath Artifacts
run: |
mkdir -p artifacts/plug-ins
cp ./build/blurPostDeform.so artifacts/plug-ins
mkdir -p artifacts/blurdeform/linux-${{matrix.year}}/plug-ins
cp ./build/blurPostDeform.so artifacts/blurdeform/linux-${{matrix.year}}/plug-ins
touch artifacts/blurdeform.mod
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: linux-${{matrix.year}}
path: artifacts/plug-ins/blurPostDeform.so
name: blurdeform
path: |
artifacts/blurdeform/linux-${{matrix.year}}/plug-ins/blurPostDeform.so
artifacts/blurdeform.mod
build_modfile:
name: Package release
needs: [maya-win, maya-linux, maya-macos]
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download artifacts
uses: actions/download-artifact@v3
with:
path: artifacts

- name: Build Modfile
run: |
python buildmodfile.py artifacts/blurdeform/blurdeform.mod --name blurdeform --path artifacts/blurdeform/blurdeform
- name: Create distribution
run: |
mkdir -p artifacts/blurdeform/blurdeform/scripts
cp -r ./scripts/blurdeform artifacts/blurdeform/blurdeform/scripts
- name: Upload Artifacts
uses: actions/upload-artifact@v3
with:
name: blurdeform
path: |
artifacts/blurdeform/blurdeform/scripts
artifacts/blurdeform/blurdeform.mod
#
# Shipping
Expand All @@ -176,46 +218,28 @@ jobs:
#
upload_release:
name: Upload release
needs: [maya-win, maya-linux, maya-macos]
needs: [maya-win, maya-linux, maya-macos, build_modfile]
runs-on: ubuntu-latest

# Only run on e.g. v0.1.0
if: startsWith(github.ref, 'refs/tags/v')

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download artifacts
uses: actions/download-artifact@v3

# Omitting name: means "download all artifacts"
# Destination directory structure:
# ~/modules
# /blurdeform
# /<os_name>-<maya_major_version>
# /plug-ins
# blurPostDeform.mll
# /blurdeform.mod

with:
path: modules/blurdeform
path: artifacts

- name: Set env
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV

- name: Create distribution
- name: Create zipfile
run: |
cp ./blurdeform.mod modules/
mkdir -p modules/blurdeform/scripts
cp -r ./scripts/blurdeform modules/blurdeform/scripts
# zip -r blurPostDeform-${{env.RELEASE_VERSION}}.zip modules/
zip -r blurPostDeform.zip modules/
zip -r blurPostDeform-${{env.RELEASE_VERSION}}.zip artifacts/blurdeform
- name: Upload distribution
uses: "marvinpinto/action-automatic-releases@latest"
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
automatic_release_tag: "latest"
prerelease: false
files: blurPostDeform.zip
files: blurPostDeform-*.zip
45 changes: 0 additions & 45 deletions blurdeform.mod

This file was deleted.

47 changes: 47 additions & 0 deletions buildmodfile.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import re
import argparse
from pathlib import Path, PurePosixPath


def main(outpath, modname, modver, modpath):
outpath = Path(outpath).absolute()

basepath = outpath.parent
modpath = Path(modpath).absolute()
modrel = modpath.relative_to(basepath)

plugPaths = list(modpath.glob(str(Path('**') / 'plug-ins')))

lines = []
for pp in plugPaths:
rel = PurePosixPath(pp.relative_to(modpath))
match = re.search(r"(?P<platform>win64|linux|mac)-(?P<year>\d+)", str(rel))
if not match:
continue
plat, year = match['platform'], match['year']
lines.append(f"+ PLATFORM:{plat} MAYAVERSION:{year} {modname} {modver} {modrel}")
lines.append(f"plug-ins: {rel}")
lines.append("")

with open(outpath, 'w') as f:
f.write('\n'.join(lines))


def parse():
parser = argparse.ArgumentParser(
prog='buildmodfile',
description='builds a mod file ensuring that plugins are loaded for the proper maya versions',
)
parser.add_argument('outpath', help="The output filepath")
parser.add_argument('-n', '--name', help="The name of the module", required=True)
parser.add_argument('-v', '--version', help="The version of the module", default="1.0.0")
parser.add_argument('-p', '--path', help="The path to the module folder", required=True)
args = parser.parse_args()

main(args.outpath, args.name, args.version, args.path)


if __name__ == "__main__":
parse()


0 comments on commit eb6effa

Please sign in to comment.