Skip to content

chore: release new version #40

chore: release new version

chore: release new version #40

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches: [main, dev]
pull_request:
branches: [main]
env:
DOCKER_IMAGE_NAME: ovos-rust-messagebus
CARGO_TERM_COLOR: always
permissions:
contents: write
packages: write
jobs:
build-binaries:
runs-on: ubuntu-latest
strategy:
matrix:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
- arm-unknown-linux-gnueabihf # This is for ARMv6
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
toolchain: stable
target: ${{ matrix.target }}
override: true
- name: Build Binary
uses: actions-rs/cargo@v1
with:
use-cross: true
command: build
args: --release --target ${{ matrix.target }}
- name: Package Binary
run: |
mkdir -p release
cp target/${{ matrix.target }}/release/ovos_messagebus release/ovos_messagebus-${{ matrix.target }}
cd release && tar czvf ovos_messagebus-${{ matrix.target }}.tar.gz ovos_messagebus-${{ matrix.target }}
sha256sum ovos_messagebus-${{ matrix.target }}.tar.gz > ovos_messagebus-${{ matrix.target }}.tar.gz.sha256
- name: Upload Binary Artifact
uses: actions/upload-artifact@v3
with:
name: ovos_messagebus-${{ matrix.target }}
path: |
release/ovos_messagebus-${{ matrix.target }}.tar.gz
release/ovos_messagebus-${{ matrix.target }}.tar.gz.sha256
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
architecture: [linux/amd64, linux/arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Lowercase Repository Name
id: lowercase_repo
run: echo "REPO_LOWERCASE=${GITHUB_REPOSITORY,,}" >> $GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
platforms: ${{ matrix.architecture }}
push: ${{ github.event_name != 'pull_request' }}
tags: |
ghcr.io/${{ steps.lowercase_repo.outputs.REPO_LOWERCASE }}:latest
ghcr.io/${{ steps.lowercase_repo.outputs.REPO_LOWERCASE }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
create-release:
needs: [build-binaries, build-and-push]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev' && github.event_name != 'pull_request'
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v3
- name: Get version from Cargo.toml
id: get_version
run: |
VERSION=$(grep '^version =' Cargo.toml | sed 's/version = "\(.*\)"/\1/')
echo "RELEASE_VERSION=v${VERSION}" >> $GITHUB_OUTPUT
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.RELEASE_VERSION }}
release_name: Release ${{ steps.get_version.outputs.RELEASE_VERSION }}
body: |-
Release of version ${{ steps.get_version.outputs.RELEASE_VERSION }}
[Automated release]
draft: false
prerelease: false
- name: Upload Release Assets
run: |
for file in ovos_messagebus-*/ovos_messagebus-*.tar.gz ovos_messagebus-*/ovos_messagebus-*.tar.gz.sha256
do
asset_name=$(basename $file)
echo "Uploading $asset_name..."
curl --data-binary @"$file" \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Content-Type: application/octet-stream" \
"https://uploads.github.com/repos/${{ github.repository }}/releases/${{ steps.create_release.outputs.id }}/assets?name=${asset_name}"
done