Skip to content

Commit

Permalink
feat: added the github workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
vitorfdl committed Jun 16, 2024
1 parent aacc6e4 commit a7fec18
Show file tree
Hide file tree
Showing 19 changed files with 701 additions and 69 deletions.
10 changes: 10 additions & 0 deletions .github/macos-build-entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
</dict>
</plist>
44 changes: 44 additions & 0 deletions .github/workflows/build-alpine-arm64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build for alpine-arm64

on: workflow_dispatch

jobs:
build:
runs-on: ubuntu-latest

steps:
# Checkout the code
- name: Checkout the code
uses: actions/checkout@v1

# Setup Docker for cross platform build
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

# Setup Docker for cross platform build
- name: Set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v1

# Build docker image
- name: Run build
run: docker buildx build --load --platform linux/arm64 -f ./docker/Dockerfile.alpine-arm64 . -t tagocore-container

# Pull binary out of docker container
- name: Extract tagocore binary out of docker
run: docker cp $(docker create tagocore-container):/usr/src/app/__build__binary__/tagocore ./tagocore

# Set binary as executable
- name: Chmod
run: chmod +x ./tagocore

# Zip the binary
- name: Generate tar.gz
run: tar cvf - tagocore | gzip > ./tagocore-alpine-arm64.tar.gz

# Upload the zip file as an artifact
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: mqttrelay-alpine-arm64
path: ../tagocore.zip
44 changes: 44 additions & 0 deletions .github/workflows/build-alpine-x64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Build for alpine-x64

on: workflow_dispatch

jobs:
build:
runs-on: ubuntu-latest

steps:
# Checkout the code
- name: Checkout the code
uses: actions/checkout@v1

# Setup Docker for cross platform build
- name: Set up QEMU
uses: docker/setup-qemu-action@v1

# Setup Docker for cross platform build
- name: Set up docker buildx
id: buildx
uses: docker/setup-buildx-action@v1

# Build docker image
- name: Run build
run: docker buildx build --load --platform linux/arm64 -f ./docker/Dockerfile.alpine-arm64 . -t tagocore-container

# Pull binary out of docker container
- name: Extract tagocore binary out of docker
run: docker cp $(docker create tagocore-container):/usr/src/app/__build__binary__/tagocore ./tagocore

# Set binary as executable
- name: Chmod
run: chmod +x ./tagocore

# Zip the binary
- name: Generate tar.gz
run: tar cvf - tagocore | gzip > ./tagocore-alpine-arm64.tar.gz

# Upload the zip file as an artifact
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: mqttrelay-alpine-arm64
path: ../tagocore.zip
31 changes: 31 additions & 0 deletions .github/workflows/build-dockerhub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Deplot to DockerHub

on:
workflow_dispatch:
inputs:
version:
description: "Version"
required: true

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout the code
uses: actions/checkout@v1

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Build and deploy images
run: bash dockerhub.sh ${{ github.event.inputs.version }}
66 changes: 66 additions & 0 deletions .github/workflows/build-macos-x64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: Build for mac-x64

on: workflow_dispatch

jobs:
build:
runs-on: macos-11

steps:
# Checkout the code
- name: Checkout code
uses: actions/checkout@v4

- name: Install Rust toolchain
run: |
rustup update --no-self-update stable
rustup component add --toolchain stable rustfmt
rustup default stable
# Build the modules
- name: Build
run: cargo build --verbose --release

- name: Run tests
run: cargo test --verbose

# # Sign the executable
# - name: Codesign binary
# env:
# MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
# MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
# MACOS_FULL_IDENTITY: ${{ secrets.MACOS_FULL_IDENTITY }}
# run: |
# echo $MACOS_CERTIFICATE | openssl base64 -d -A > certificate.p12
# security create-keychain -p $MACOS_CERTIFICATE_PWD build.keychain
# security default-keychain -s build.keychain
# security unlock-keychain -p $MACOS_CERTIFICATE_PWD build.keychain
# security import certificate.p12 -k build.keychain -P $MACOS_CERTIFICATE_PWD -T /usr/bin/codesign
# security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $MACOS_CERTIFICATE_PWD build.keychain
# cd __build__binary__
# /usr/bin/codesign -f -s "$MACOS_FULL_IDENTITY" --entitlements ../.github/macos-build-entitlements.plist --options=runtime --timestamp ./tagocore
# zip ./tagocore.zip ./tagocore
# /usr/bin/codesign -f -s "$MACOS_FULL_IDENTITY" --options=runtime --timestamp ./tagocore.zip

# # Notarize app using xcrun altool
# - name: Notarize binary
# env:
# MACOS_DEVELOPER_EMAIL: ${{ secrets.MACOS_DEVELOPER_EMAIL }}
# MACOS_DEVELOPER_PWD: ${{ secrets.MACOS_DEVELOPER_PWD }}
# MACOS_BUNDLE_ID: ${{ secrets.MACOS_BUNDLE_ID }}
# MACOS_ASC_PROVIDER: ${{ secrets.MACOS_ASC_PROVIDER }}
# run: xcrun altool --notarize-app --primary-bundle-id "$MACOS_BUNDLE_ID" -u "$MACOS_DEVELOPER_EMAIL" -p "$MACOS_DEVELOPER_PWD" --asc-provider "$MACOS_ASC_PROVIDER" -f ./__build__binary__/tagocore.zip

# Zip the binary
- name: Generate tar.gz
run: |
cd __build__binary__
unzip -o tagocore.zip
tar cvf - tagocore | gzip > ../tagocore-mac-x64.tar.gz
# Upload the zip file as an artifact
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: mqttrelay-macos-x64
path: ../tagocore.zip
47 changes: 47 additions & 0 deletions .github/workflows/build-win-x64.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build for win-x64

on: workflow_dispatch

jobs:
build:
runs-on: ubuntu-latest

steps:
# Checkout the code
- name: Checkout the code
uses: actions/checkout@v1

# Install dependencies
- name: Install dependencies
run: npm install

# Build the modules
- name: Run build
run: npm run build

# Manually copy the bin file of sdk to the .bin folder to use the local copy of the sdk
- name: Override tcore-plugin .bin file
run: cd ./node_modules/.bin; ln -s ../../packages/tcore-sdk/build/Bin/Bin.js tcore-plugin; chmod +x tcore-plugin; cd ../../

# Pack Plugin Store, TagoIO Integration, and Local Filesystem into a .tcore file
- name: Pack built-in plugins
run: npm run pack

# Add the packed .tcore files to the /plugins folder
- name: Move built-in plugins to plugins folder
run: npm run plugin:add

# Generate the executable
- name: Generate executable
run: ./node_modules/.bin/pkg package.json -t node16-win-x64 --public-packages "*" --no-bytecode --public --compress Brotli

# Zip the executable
- name: Generate zip
run: cd __build__binary__; zip ../tagocore.zip ./tagocore.exe

# Upload the zip file as an artifact
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: mqttrelay-windows-x64
path: ../tagocore.zip
31 changes: 15 additions & 16 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,23 @@ jobs:
runs-on: ubuntu-latest

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

- name: Install Rust toolchain
run: |
rustup update --no-self-update stable
rustup component add --toolchain stable rustfmt
rustup default stable
- name: Install Rust toolchain
run: |
rustup update --no-self-update stable
rustup component add --toolchain stable rustfmt
rustup default stable
- name: Build
run: cargo build --verbose
- name: Build
run: cargo build --verbose

- name: Run tests
run: cargo test --verbose
- name: Run tests
run: cargo test --verbose

- name: Run clippy
run: cargo clippy -- -D warnings

- name: Run fmt check
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy -- -D warnings

- name: Run fmt check
run: cargo fmt -- --check
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ mockito = "1.4.0"
[dependencies]
anyhow = "1.0.86"
axum = "0.7.5"
axum-server = { version = "0.6", features = ["tls-rustls"] }
axum-server = { version = "0.6.0", features = ["tls-rustls", "tls-openssl"] }
clap = { version = "4.5.4", features = ["derive"] }
config = "0.14.0"
dotenvy = "0.15.7"
Expand All @@ -18,6 +18,7 @@ env_logger = "0.11.3"
home = "0.5.9"
log = "0.4.21"
once_cell = "1.19.0"
openssl = "0.10.64"
rand = "0.8.5"
regex = "1.10.4"
reqwest = { version = "0.12.4", features = ["rustls-tls", "json"] }
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ RUN apt-get clean && rm -rf /var/lib/apt/lists/*
RUN mkdir -p ${TAGOIO_SOURCE_FOLDER}
WORKDIR ${TAGOIO_SOURCE_FOLDER}
COPY --from=build ${TAGOIO_SOURCE_FOLDER}/target/release/tagoio-mqtt-relay .
COPY --from=build ${TAGOIO_SOURCE_FOLDER}/config.toml config.toml

RUN /tago-io/tagoio-mqtt-relay init

ENTRYPOINT ["/tago-io/tagoio-mqtt-relay"]
CMD ["start"]
Loading

0 comments on commit a7fec18

Please sign in to comment.