Skip to content

Commit

Permalink
ci: Refactor workflows (#78)
Browse files Browse the repository at this point in the history
  • Loading branch information
KokaKiwi authored Sep 26, 2024
1 parent 7723255 commit c5fc024
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 195 deletions.
28 changes: 0 additions & 28 deletions .github/workflows/build-aarch64-darwin.yml

This file was deleted.

28 changes: 0 additions & 28 deletions .github/workflows/build-aarch64-linux.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/build-x86_64-darwin.yml

This file was deleted.

29 changes: 0 additions & 29 deletions .github/workflows/build-x86_64-linux.yml

This file was deleted.

26 changes: 26 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
42 changes: 21 additions & 21 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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
107 changes: 47 additions & 60 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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/**
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
11 changes: 11 additions & 0 deletions Cargo.lock

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

6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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",
]

0 comments on commit c5fc024

Please sign in to comment.