Improving deployment #22
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CD | ||
on: | ||
push: | ||
tags: | ||
- "[0-9]+.[0-9]+.[0-9]+" | ||
workflow_dispatch: | ||
workflow_run: # when CI passes (check && test && clippy), deploy | ||
workflows: ["CI"] | ||
types: | ||
- completed | ||
permissions: | ||
contents: write | ||
jobs: | ||
check_tags: | ||
if: ${{ !startsWith(github.ref, 'refs/tags/') }} | ||
uses: reecetech/[email protected] | ||
id: version | ||
with: | ||
scheme: semver | ||
increment: patch | ||
build: | ||
name: Build platform libs | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# You can add more, for any target you'd like! | ||
include: | ||
# Debug linux | ||
- target: x86_64-unknown-linux-gnu | ||
artifact: libsqore.so | ||
type: debug | ||
# Debug mac | ||
- target: x86_64-apple-darwin | ||
artifact: libsqore.dylib | ||
type: debug | ||
# Debug Windows | ||
- target: x86_64-pc-windows-gnu | ||
artifact: sqore.dll | ||
type: debug | ||
# Release linux | ||
- target: x86_64-unknown-linux-gnu | ||
artifact: libsqore.so | ||
type: release | ||
# Release mac | ||
- target: x86_64-apple-darwin | ||
artifact: libsqore.dylib | ||
type: release | ||
# Release windows | ||
- target: x86_64-pc-windows-gnu | ||
artifact: sqore.dll | ||
type: release | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Get the release version from the tag | ||
shell: bash | ||
run: echo "VERSION=$\{GITHUB_REF#refs/tags/\}" >> $GITHUB_ENV | ||
- name: Install Rust | ||
# Or @nightly if you want | ||
uses: dtolnay/rust-toolchain@stable | ||
# Arguments to pass in | ||
with: | ||
# Make Rust compile to our target (defined in the matrix) | ||
targets: ${{ matrix.target }} | ||
- name: Build Release | ||
uses: actions-rs/cargo@v1 | ||
if: matrix.type == 'release' # gotta be a better way? | ||
with: | ||
use-cross: true | ||
command: build | ||
args: --verbose --release --target ${{ matrix.target }} | ||
- name: Build Debug | ||
uses: actions-rs/cargo@v1 | ||
if: matrix.type == 'debug' | ||
with: | ||
use-cross: true | ||
command: build | ||
args: --verbose --target ${{ matrix.target }} | ||
- name: Upload lib | ||
uses: actions/[email protected] | ||
with: | ||
name: ${{ matrix.artifact }}--${{ matrix.type }} | ||
if-no-files-found: error | ||
path: "target/${{ matrix.target }}/${{matrix.type}}/${{ matrix.artifact }}" | ||
overwrite: true | ||
package: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: start package | ||
run: | | ||
mkdir addons | ||
mkdir addons/sqore | ||
mkdir addons/sqore/target | ||
mkdir addons/sqore/target/debug | ||
mkdir addons/sqore/target/release | ||
mkdir libs | ||
mkdir libs/debug | ||
mkdir libs/release | ||
- name: Install Rust | ||
uses: dtolnay/rust-toolchain@stable | ||
- name: Build docs | ||
uses: actions-rs/cargo@v1 | ||
with: | ||
use-cross: false | ||
command: doc | ||
args: --verbose --no-deps --target-dir . | ||
- name: download debug files | ||
uses: actions/[email protected] | ||
with: | ||
# Destination path. Supports basic tilde expansion. Defaults to $GITHUB_WORKSPACE | ||
path: "libs/debug/" | ||
# A glob pattern matching the artifacts that should be downloaded. Ignored if name is specified. | ||
pattern: "*sqore*--debug" | ||
- name: download release files | ||
uses: actions/[email protected] | ||
with: | ||
# Destination path. Supports basic tilde expansion. Defaults to $GITHUB_WORKSPACE | ||
path: "libs/release/" | ||
# A glob pattern matching the artifacts that should be downloaded. Ignored if name is specified. | ||
pattern: "*sqore*--release" | ||
- name: move files | ||
run: | | ||
for d in $(ls libs/debug/**/*sqore*); | ||
do cp $d addons/sqore/target/debug/ | ||
done; | ||
for r in $(ls libs/release/**/*sqore*); | ||
do cp $r addons/sqore/target/release/ | ||
done; | ||
cp README.md addons/sqore/README.md | ||
cp LICENSE addons/sqore/LICENSE | ||
cp sqore.gdextension addons/sqore/sqore.gdextension | ||
cp -r scenes addons/sqore/scenes/ | ||
cp -r assets addons/sqore/assets/ | ||
cp -r doc addons/sqore/doc/ | ||
zip -r -q sqore_release addons | ||
ls -1 | ||
- name: Make Release | ||
if: startsWith(github.ref, 'refs/tags/') | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: sqore_release.zip |