From 6ee0ce3f7fb9e7c0a656d5d6922ac1fee35d199a Mon Sep 17 00:00:00 2001 From: genofire Date: Tue, 17 Oct 2023 18:28:48 +0200 Subject: [PATCH] chore(ci): improve workflow --- .github/workflows/build.yml | 95 +++++++++++++++++++ .../{image.yml => container-image.yml} | 1 + 2 files changed, 96 insertions(+) create mode 100644 .github/workflows/build.yml rename .github/workflows/{image.yml => container-image.yml} (97%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..2f612d3 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,95 @@ +on: + workflow_dispatch: + push: + branches: + - "**" + tags: + - "\\d+\\.\\d+\\.\\d+" + pull_request: + branches: + - "main" + +jobs: + test: + name: "Test (rust unit)" + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install dependencies on Linux + run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools libssl-dev + + - name: Compile + id: compile + uses: houseabsolute/actions-rust-cross@v0 + with: + target: "x86_64-unknown-linux-musl" + command: test + + build: + name: "Build (and Archive) binary" + runs-on: ubuntu-latest + + strategy: + matrix: + rusttarget: + - "x86_64-unknown-linux-musl" + - "aarch64-unknown-linux-musl" + - "arm-unknown-linux-musleabi" + - "x86_64-pc-windows-msvc" + - "x86_64-apple-darwin" + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Install dependencies + run: sudo apt-get update --yes && sudo apt-get install --yes libsss-dev + + - name: Install musl-tools on Linux + run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools + if: contains(matrix.rusttarget, 'musl') + + - name: Compile + uses: houseabsolute/actions-rust-cross@v0 + with: + target: ${{ matrix.rusttarget }} + command: build + args: "--locked --release" + + - name: Archive build artifacts + uses: actions/upload-artifact@v3 + with: + name: binary + path: target/${{ matrix.rusttarget }}/release/mollysocket + + release: + runs-on: ubuntu-latest + if: github.ref == 'refs/heads/main' + needs: + - test + - build + steps: + - name: Download build artifacts + uses: actions/download-artifact@v3 + with: + name: binary + path: dist/ + + - name: Semantic-Release + uses: codfish/semantic-release-action@v2 + with: + plugins: |- + [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + [ "@semantic-release/github", { + "assets": [ + { "path": "dist/*" } + ] + }] + ] + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/image.yml b/.github/workflows/container-image.yml similarity index 97% rename from .github/workflows/image.yml rename to .github/workflows/container-image.yml index 5941970..42c9204 100644 --- a/.github/workflows/image.yml +++ b/.github/workflows/container-image.yml @@ -16,6 +16,7 @@ on: jobs: build: + name: "Build and publish container image" runs-on: ubuntu-latest steps: - name: checkout code