diff --git a/.github/workflows/build-aarch64-darwin.yml b/.github/workflows/build-aarch64-darwin.yml deleted file mode 100644 index e581c68..0000000 --- a/.github/workflows/build-aarch64-darwin.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Build aarch64-darwin - -on: - workflow_call: - inputs: - cache-key: - type: string - required: false - default: "aarch64-darwin-artifact-${{ github.sha }}" -jobs: - build: - name: Build aarch64-darwin - runs-on: macos-latest - concurrency: ${{ inputs.cache-key }} - permissions: - id-token: write - contents: read - steps: - - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - - name: Build aarch64-darwin - run: make ci.aarch64-darwin - - name: Create Github cache - uses: actions/cache/save@v3 - with: - path: build - key: ${{ inputs.cache-key }} \ No newline at end of file diff --git a/.github/workflows/build-aarch64-linux.yml b/.github/workflows/build-aarch64-linux.yml deleted file mode 100644 index 1b675af..0000000 --- a/.github/workflows/build-aarch64-linux.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: Build aarch64-linux - -on: - workflow_call: - inputs: - cache-key: - type: string - required: false - default: "aarch64-linux-artifact-${{ github.sha }}" -jobs: - build: - name: Build aarch64-linux - runs-on: ubuntu-latest - concurrency: ${{ inputs.cache-key }} - permissions: - id-token: write - contents: read - steps: - - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - - name: Build aarch64-darwin - run: make ci.aarch64-darwin - - name: Create Github cache - uses: actions/cache/save@v3 - with: - path: build - key: ${{ inputs.cache-key }} \ No newline at end of file diff --git a/.github/workflows/build-x86_64-darwin.yml b/.github/workflows/build-x86_64-darwin.yml deleted file mode 100644 index 4b7f31c..0000000 --- a/.github/workflows/build-x86_64-darwin.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Build x86_64-darwin - -on: - workflow_call: - inputs: - cache-key: - type: string - required: false - default: x86_64-darwin-artifacts-${{ github.sha }} - -jobs: - build-x86_64-darwin: - name: Build x86_64 Darwin - runs-on: macos-13-large - concurrency: ${{ inputs.cache-key }} - permissions: - id-token: "write" - contents: "read" - steps: - - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - - name: Build the installer - run: make ci.x86_64-darwin - - name: Create GitHub cache - uses: actions/cache/save@v3 - with: - path: build - key: ${{ inputs.cache-key }} \ No newline at end of file diff --git a/.github/workflows/build-x86_64-linux.yml b/.github/workflows/build-x86_64-linux.yml deleted file mode 100644 index 2b35cf8..0000000 --- a/.github/workflows/build-x86_64-linux.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: Build x86_64-inux - -on: - workflow_call: - inputs: - cache-key: - type: string - required: false - default: x86_64-linux-artifacts-${{ github.sha }} - -jobs: - build-x86_64-linux: - name: Build x86_64 Linux (static) - runs-on: UbuntuLatest32Cores128G - concurrency: ${{ inputs.cache-key }} - permissions: - id-token: "write" - contents: "read" - steps: - - uses: actions/checkout@v4 - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - - name: Build the installer - run: make ci.x86_64-linux - - name: Create GitHub cache from build artifacts - uses: actions/cache/save@v3 - with: - path: build - key: ${{ inputs.cache-key }} \ No newline at end of file diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..352b435 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,26 @@ +name: Run tests +on: + push: + branches: + - main + pull_request: + +jobs: + test: + name: cargo test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + - run: cargo test --locked + fmt: + name: cargo fmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions-rust-lang/setup-rust-toolchain@v1 + with: + components: rustfmt + - uses: actions-rust-lang/rustfmt@v1 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 6191bc0..f4a828b 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -1,35 +1,35 @@ -name: "Publish Releases" +name: Publish releases on: release: types: [published] jobs: cratesio: - name: Publish to Crates.io + name: Publish to crates.io runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: actions-rs/toolchain@v1 - with: - toolchain: stable - override: true - - run: cargo fetch + - uses: actions-rust-lang/setup-rust-toolchain@v1 - name: cargo publish run: cargo publish --token ${{ secrets.CRATES_IO_TOKEN }} docker: - name: "Publish to Docker Hub" - runs-on: "ubuntu-latest" - permissions: - id-token: "write" - contents: "read" + name: Publish to DockerHub + strategy: + matrix: + platform: + - os: ubuntu-latest + platform: linux/amd64 + runs-on: ${{ matrix.platform.os }} steps: - - uses: "actions/checkout@v4" + - uses: actions/checkout@v4 + - uses: docker/setup-qemu-action@v3 + - uses: docker/setup-buildx-action@v3 + - uses: docker/login-action@v3 with: - ref: "${{ github.ref_name }}" - - uses: "docker/login-action@v2" + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_TOKEN }} + - uses: docker/build-push-action@v6 with: - username: "${{ secrets.DOCKER_USERNAME }}" - password: "${{ secrets.DOCKER_PASSWORD }}" - - run: "docker build -t edgeecloud/edgee:${{ github.ref_name }} ." - - run: "docker push edgeecloud/edgee:${{ github.ref_name }}" - - run: "docker push edgeecloud/edgee:latest" - + push: true + tags: | + edgeecloud/edgee:${{ github.ref_name }} + edgeecloud/edgee:latest diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5bae87c..03ef3c8 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,62 +1,49 @@ -name: Release - +name: Build release +permissions: + contents: write on: - push: - tags: - - "v*.*.*" - + workflow_dispatch: + push: + tags: + - 'v*' jobs: - build-x86_64-linux: { uses: ./.github/workflows/build-x86_64-linux.yml } - build-x86_64-darwin: { uses: ./.github/workflows/build-x86_64-darwin.yml } - build-aarch64-linux: { uses: ./.github/workflows/build-aarch64-linux.yml } - build-aarch64-darwin: { uses: ./.github/workflows/build-aarch64-darwin.yml } - - release: - runs-on: ubuntu-latest - needs: - - build-x86_64-linux - - build-x86_64-darwin - - build-aarch64-linux - - build-aarch64-darwin - steps: - - uses: actions/checkout@v4 - - name: Create artifacts directory - run: mkdir -p ./artifacts - - - uses: actions/cache/restore@v3 - name: Restore x86_64-linux artifacts - with: - path: build - key: x86_64-linux-artifacts-${{ github.sha }} - - name: Move x86_64-linux artifacts - run: mv ./build ./artifacts/x86_64-linux - - - uses: actions/cache/restore@v3 - name: Restore x86_64-darwin artifacts - with: - path: build - key: x86_64-darwin-artifacts-${{ github.sha }} - - name: Move x86_64-darwin artifacts - run: mv ./build ./artifacts/x86_64-darwin - - - uses: actions/cache/restore@v3 - name: Restore aarch64-linux artifacts - with: - path: build - key: aarch64-linux-artifacts-${{ github.sha }} - - name: Move aarch64-linux artifacts - run: mv ./build ./artifacts/aarch64-linux - - - uses: actions/cache/restore@v3 - name: Restore aarch64-darwin artifacts - with: - path: build - key: aarch64-darwin-artifacts-${{ github.sha }} - - - name: Publish Release to GitHub - uses: softprops/action-gh-release@v1 - with: - fail_on_unmatched_files: true - draft: true - files: | - artifacts/** \ No newline at end of file + build-release-binaries: + strategy: + matrix: + platform: + - os: ubuntu-latest + target: x86_64-unknown-linux-gnu + features: bundled + - os: macos-latest + target: x86_64-apple-darwin + features: bundled + - os: macos-latest + target: aarch64-apple-darwin + features: bundled + name: Build release binary (${{ matrix.platform.target }} on ${{ matrix.platform.os }}) + runs-on: ${{ matrix.platform.os }} + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup cache + uses: Swatinem/rust-cache@v2 + - name: Build binary + uses: houseabsolute/actions-rust-cross@v0 + with: + command: ${{ matrix.platform.command }} + target: ${{ matrix.platform.target }} + args: '--release --features "${{ matrix.platform.features }}"' + - name: Save binary + uses: actions/upload-artifact@v4 + with: + name: edgee.${{ matrix.platform.target }} + path: target/${{ matrix.platform.target }}/release/edgee + retention-days: 3 + - run: cp target/${{ matrix.platform.target }}/release/edgee edgee.${{ matrix.platform.target }} + - name: Publish artifacts and release + uses: xresloader/upload-to-github-release@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + file: edgee.${{ matrix.platform.target }} + tags: true diff --git a/Cargo.lock b/Cargo.lock index 59a01ae..0277ee7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -772,6 +772,7 @@ dependencies = [ "json_comments", "libflate", "log", + "openssl", "rand", "regex", "reqwest", @@ -1677,6 +1678,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" +[[package]] +name = "openssl-src" +version = "300.3.1+3.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7259953d42a81bf137fbbd73bd30a8e1914d6dce43c2b90ed575783a22608b91" +dependencies = [ + "cc", +] + [[package]] name = "openssl-sys" version = "0.9.103" @@ -1685,6 +1695,7 @@ checksum = "7f9e8deee91df40a943c71b917e5874b951d32a802526c85721ce3b776c929d6" dependencies = [ "cc", "libc", + "openssl-src", "pkg-config", "vcpkg", ] diff --git a/Cargo.toml b/Cargo.toml index 0cc703e..aee7622 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,7 @@ ipnetwork = "0.20.0" json_comments = "0.2.2" libflate = "2.1.0" log = "0.4" +openssl = "0.10" rand = "0.8.5" regex = "1.10.4" reqwest = "0.12.5" @@ -49,3 +50,8 @@ url = "2.5.2" uuid = { version = "1.9.1", features = ["v4", "serde"] } wasmtime = "22.0.0" wasmtime-wasi = "22.0.0" + +[features] +bundled = [ + "openssl/vendored", +]