Skip to content
This repository has been archived by the owner on Nov 2, 2023. It is now read-only.

Commit

Permalink
chore(ci): improve workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
genofire committed Oct 17, 2023
1 parent e8169ef commit 9d3ba5b
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 0 deletions.
98 changes: 98 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
name: "Build, Test and Release"

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 libsqlite3-0

- name: Compile
id: compile
uses: houseabsolute/actions-rust-cross@v0
with:
target: "x86_64-unknown-linux-gnu"
command: test

build:
name: "Build (and Archive) binary"
runs-on: ubuntu-latest

strategy:
matrix:
platform:
- target: "x86_64-unknown-linux-gnu"
suffix: "x86_64"

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

- name: Install dependencies
run: sudo apt-get update --yes && sudo apt-get install --yes libssl-dev libsqlite3-0

- name: Install musl-tools on Linux
run: sudo apt-get update --yes && sudo apt-get install --yes musl-tools
if: contains(matrix.platform.target, 'musl')

- name: Compile
uses: houseabsolute/actions-rust-cross@v0
with:
target: ${{ matrix.platform.target }}
command: build
args: "--locked --release"
strip: true

- name: Prepare for upload
run: mv "target/${{ matrix.platform.target }}/release/mollysocket" "mollysocket_${{matrix.platform.suffix}}"

- name: Archive build artifacts
uses: actions/upload-artifact@v3
with:
name: binary
path: "mollysocket_${{matrix.platform.suffix}}"

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 }}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ on:

jobs:
build:
name: "Build and publish container image"
runs-on: ubuntu-latest
steps:
- name: checkout code
Expand Down

0 comments on commit 9d3ba5b

Please sign in to comment.