Skip to content

Commit

Permalink
Another attempt at getting Github Actions Working
Browse files Browse the repository at this point in the history
  • Loading branch information
Vadoola committed Oct 4, 2024
1 parent ba57fa2 commit 1d15551
Show file tree
Hide file tree
Showing 3 changed files with 102 additions and 75 deletions.
94 changes: 63 additions & 31 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,43 @@
#
# REF:
# 1. https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstrategymatrixinclude
#
#https://dzfrias.dev/blog/deploy-rust-cross-platform-github-actions/

name: Create Release

on:
workflow_dispatch:
push:
tags: ["[0-9]+.[0-9]+.[0-9]+*"]

defaults:
run:
shell: bash

jobs:
standard:
name: dxf2elmt
build-and-upload:
name: Build and upload
runs-on: ${{ matrix.os }}

strategy:
fail-fast: false
#fail-fast: false
matrix:
include:
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
extra: 'bin'
os: windows-latest
- target: x86_64-pc-windows-msvc
extra: msi
os: windows-latest
- target: x86_64-unknown-linux-gnu
os: ubuntu-22.04
- target: x86_64-unknown-linux-musl
os: ubuntu-22.04
- build: linux-musl
os: ubuntu-latest
target: x86_64-unknown-linux-musl

- build: macos
os: macos-latest
target: x86_64-apple-darwin

- build: macos-arm
os: macos-latest
target: aarch64-apple-darwin

#- build: windows-gnu
# os: windows-latest
# target: x86_64-pc-windows-gnu

- build: windows-msvc
os: windows-latest
target: x86_64-pc-windows-msvc

- build: linux
os: ubuntu-latest
target: x86_64-unknown-linux-gnu

runs-on: ${{matrix.os}}

Expand All @@ -45,9 +48,38 @@ jobs:
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Upload package artifacts
uses: actions/upload-artifact@v4
- name: Get the release version from the tag
shell: bash
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Build
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --verbose --release --target ${{ matrix.target }}
- name: Build archive
shell: bash
run: |
# Replace with the name of your binary
binary_name="<BINARY_NAME>"
dirname="$binary_name-${{ env.VERSION }}-${{ matrix.target }}"
mkdir "$dirname"
if [ "${{ matrix.os }}" = "windows-latest" ]; then
mv "target/${{ matrix.target }}/release/$binary_name.exe" "$dirname"
else
mv "target/${{ matrix.target }}/release/$binary_name" "$dirname"
fi
if [ "${{ matrix.os }}" = "windows-latest" ]; then
7z a "$dirname.zip" "$dirname"
echo "ASSET=$dirname.zip" >> $GITHUB_ENV
else
tar -czf "$dirname.tar.gz" "$dirname"
echo "ASSET=$dirname.tar.gz" >> $GITHUB_ENV
fi
- name: Upload the binaries
uses: softprops/action-gh-release@v1
with:
name: ${{ matrix.arch }}
path: artifacts/
if-no-files-found: error
files: |
${{ env.ASSET }}
1 change: 0 additions & 1 deletion src/qelmt/line.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ impl TryFrom<&LwPolyline> for Line {
}
}


impl From<&Line> for XMLElement {
fn from(line: &Line) -> Self {
let mut line_xml: XMLElement = XMLElement::new("line");
Expand Down
82 changes: 39 additions & 43 deletions src/qelmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,52 +195,48 @@ impl TryFrom<(&Entity, u32, f64, f64)> for Objects {
ellipse.y -= offset_y;
Ok(Objects::Ellipse(ellipse))
}
EntityType::Polyline(ref polyline) => {
match polyline.__vertices_and_handles.len() {
0 | 1 => Err("Error empty Polyline"),
2 => {
let mut line = Line::try_from(polyline)?;
line.x1 += offset_x;
line.y1 -= offset_y;

line.x2 += offset_x;
line.y2 -= offset_y;

Ok(Objects::Line(line))
}
_ => {
let mut poly: Polygon = polyline.into();
for cord in &mut poly.coordinates {
cord.x += offset_x;
cord.y -= offset_y;
}
Ok(Objects::Polygon(poly))
}
EntityType::Polyline(ref polyline) => match polyline.__vertices_and_handles.len() {
0 | 1 => Err("Error empty Polyline"),
2 => {
let mut line = Line::try_from(polyline)?;
line.x1 += offset_x;
line.y1 -= offset_y;

line.x2 += offset_x;
line.y2 -= offset_y;

Ok(Objects::Line(line))
}
}
EntityType::LwPolyline(ref lwpolyline) => {
match lwpolyline.vertices.len() {
0 | 1 => Err("Error empty LwPolyline"),
2 => {
let mut line = Line::try_from(lwpolyline)?;
line.x1 += offset_x;
line.y1 -= offset_y;

line.x2 += offset_x;
line.y2 -= offset_y;

Ok(Objects::Line(line))
_ => {
let mut poly: Polygon = polyline.into();
for cord in &mut poly.coordinates {
cord.x += offset_x;
cord.y -= offset_y;
}
_ => {
let mut poly: Polygon = lwpolyline.into();
for cord in &mut poly.coordinates {
cord.x += offset_x;
cord.y -= offset_y;
}
Ok(Objects::Polygon(poly))
Ok(Objects::Polygon(poly))
}
},
EntityType::LwPolyline(ref lwpolyline) => match lwpolyline.vertices.len() {
0 | 1 => Err("Error empty LwPolyline"),
2 => {
let mut line = Line::try_from(lwpolyline)?;
line.x1 += offset_x;
line.y1 -= offset_y;

line.x2 += offset_x;
line.y2 -= offset_y;

Ok(Objects::Line(line))
}
_ => {
let mut poly: Polygon = lwpolyline.into();
for cord in &mut poly.coordinates {
cord.x += offset_x;
cord.y -= offset_y;
}
Ok(Objects::Polygon(poly))
}
}
},
EntityType::Solid(ref solid) => {
let mut poly: Polygon = solid.into();

Expand Down Expand Up @@ -335,7 +331,7 @@ impl From<(&Drawing, u32)> for Description {
println!("{}", drw.header.file_name);
println!("{}", drw.header.project_name);
println!("{:?}", drw.header.unit_format);*/

Self {
objects: drw
.entities()
Expand Down

0 comments on commit 1d15551

Please sign in to comment.