Skip to content

Commit

Permalink
automate build
Browse files Browse the repository at this point in the history
  • Loading branch information
qguv committed Jul 14, 2024
1 parent a33bdb7 commit 9c1b4ba
Show file tree
Hide file tree
Showing 7 changed files with 172 additions and 22 deletions.
156 changes: 156 additions & 0 deletions .github/workflows/render.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
name: render
on: push
jobs:
render:
runs-on: ubuntu-22.04
steps:

- name: download ninja binary
run: curl -LO https://github.com/ninja-build/ninja/releases/download/v1.10.2/ninja-linux.zip

- name: extract ninja binary
run: unzip ninja-linux.zip

- name: install ninja
run: sudo install ninja /usr/local/bin/

- name: update system
run: sudo apt-get update

- name: install openscad
run: sudo apt-get install -y --no-install-recommends openscad xvfb

- uses: actions/checkout@v4
with:
submodules: true

- name: render 3mf
run: ninja a5-stop.3mf

- name: add commit hash to 3mf filename
run: mv a5-stop.3mf a5-stop_${{ github.sha }}.3mf

- name: upload 3mf
uses: actions/upload-artifact@v2
with:
name: a5-stop_${{ github.sha }}.3mf
path: a5-stop_${{ github.sha }}.3mf

- name: render stl
run: ninja a5-stop.stl

- name: add commit hash to stl filename
run: mv a5-stop.stl a5-stop_${{ github.sha }}.stl

- name: upload stl
uses: actions/upload-artifact@v2
with:
name: a5-stop_${{ github.sha }}.stl
path: a5-stop_${{ github.sha }}.stl

- name: render png
uses: coactions/setup-xvfb@v1
with:
run: ninja a5-stop.png

- name: add commit hash to png filename
run: mv a5-stop.png a5-stop_${{ github.sha }}.png

- name: upload png
uses: actions/upload-artifact@v2
with:
name: a5-stop_${{ github.sha }}.png
path: a5-stop_${{ github.sha }}.png

github-release:
needs: render
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:

- name: calculate new version
uses: frabert/replace-string-action@v1.1
with:
string: ${{ github.ref }}
pattern: 'refs/tags/v'
replace-with: ''
id: version

- name: download 3mf
uses: actions/download-artifact@v2
with:
name: a5-stop_${{ github.sha }}.3mf

- name: download stl
uses: actions/download-artifact@v2
with:
name: a5-stop_${{ github.sha }}.stl

- name: create github release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
body: |
![2d render](https://qguv.github.io/a5-stop/img/a5-stop_${{ steps.version.outputs.replaced }}.png)
tag_name: ${{ github.ref }}
release_name: Release ${{ steps.version.outputs.replaced }}
draft: true
prerelease: ${{ startsWith(github.ref, 'refs/tags/v0.') }}
id: create_release

- name: upload 3mf as a release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: a5-stop_${{ github.sha }}.3mf
asset_name: a5-stop_${{ steps.version.outputs.replaced }}.3mf
asset_content_type: application/octet-stream

- name: upload stl as a release asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: a5-stop_${{ github.sha }}.stl
asset_name: a5-stop_${{ steps.version.outputs.replaced }}.stl
asset_content_type: application/octet-stream

gh-pages-release:
needs: render
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:

- name: calculate new version
uses: frabert/replace-string-action@v1.1
with:
string: ${{ github.ref }}
pattern: 'refs/tags/v'
replace-with: ''
id: version

- uses: actions/download-artifact@v2
with:
name: a5-stop_${{ github.sha }}.png

- name: upload rendered image
run: |
mkdir -p gh-pages/img
cp a5-stop_${{ github.sha }}.png gh-pages/img/a5-stop.png
cp a5-stop_${{ github.sha }}.png gh-pages/img/a5-stop_${{ steps.version.outputs.replaced }}.png
- name: deploy to github pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: gh-pages/
keep_files: true
enable_jekyll: false
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.ninja_log
pillstack.3mf
*.3mf
*.stl
*.png
3 changes: 0 additions & 3 deletions .gitmodules

This file was deleted.

1 change: 0 additions & 1 deletion BOSL2
Submodule BOSL2 deleted from 46f783
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
# a5 alignment stop

A5 alignment stop for the Dahle 507 paper cutter
_also available [on Printables]()_

## building

once you have the submodules (`git submodule update --init`), run `ninja` or `openscad -o a5.3mf a5.scad`
![3d render of object](https://qguv.github.io/a5-stop/img/a5-stop.png)

## animation
Customizable, 3d-printable A5 alignment stop for the Dahle 507 paper cutter.

some animations are included at the beginning of pillstack.scad. you can uncomment them (one at a time) to view them. from the OpenSCAD GUI, select View → Animate, then set FPS to 30 and Steps to 360
## building

note: this seems to prevent OpenSCAD from automatically updating the preview when the source changes
run `ninja` or `openscad -o a5.3mf a5.scad`
9 changes: 1 addition & 8 deletions a5-stop.scad
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
// animation: fix camera in place
//$vpr = [$vpr[0], 0, $vpr[2]];
//$vpt = [0, 0, 0];

// animation: spin
//$vpr = [$vpr[0], 0, 360 * $t];

include <BOSL2/std.scad>

$fn = 90;
Expand Down Expand Up @@ -60,4 +53,4 @@ module all() {
}
}

all();
all();
9 changes: 7 additions & 2 deletions build.ninja
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
rule openscad
rule render3d
command = openscad -o $out $in

build a5-stop.3mf: openscad a5-stop.scad
rule render2d
command = openscad --colorscheme BeforeDawn -o $out $in

build a5-stop.3mf: render3d a5-stop.scad
build a5-stop.stl: render3d a5-stop.scad
build a5-stop.png: render2d a5-stop.scad

0 comments on commit 9c1b4ba

Please sign in to comment.