Skip to content

Commit

Permalink
fix: automated release workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejgray committed Dec 12, 2024
1 parent 533f7a0 commit 2475d0c
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 57 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
name: CI/CD Pipeline
name: Release Build

on:
push:
branches: [main, dev]
pull_request:
branches: [main]
release:
types: [created]

env:
DOCKER_IMAGE_NAME: ovos-rust-messagebus
CARGO_TERM_COLOR: always

permissions:
Expand All @@ -20,7 +17,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
target:
target:
- x86_64-unknown-linux-gnu
- aarch64-unknown-linux-gnu
- armv7-unknown-linux-gnueabihf
Expand Down Expand Up @@ -69,12 +66,12 @@ jobs:
sha256sum ovos_messagebus-${{ matrix.target }}.tar.gz > ovos_messagebus-${{ matrix.target }}.tar.gz.sha256
fi
- name: Upload Binary Artifact
uses: actions/upload-artifact@v3
with:
name: ovos_messagebus-${{ matrix.target }}
path: |
release/ovos_messagebus-${{ matrix.target }}.tar.gz
- name: Upload Release Asset
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release upload ${{ github.event.release.tag_name }} \
release/ovos_messagebus-${{ matrix.target }}.tar.gz \
release/ovos_messagebus-${{ matrix.target }}.tar.gz.sha256
build-and-push:
Expand Down Expand Up @@ -110,51 +107,10 @@ jobs:
context: .
file: ./Dockerfile
platforms: ${{ matrix.architecture }}
push: ${{ github.event_name != 'pull_request' }}
push: true
tags: |
ghcr.io/${{ steps.lowercase_repo.outputs.REPO_LOWERCASE }}:latest
ghcr.io/${{ steps.lowercase_repo.outputs.REPO_LOWERCASE }}:${{ github.sha }}
ghcr.io/${{ steps.lowercase_repo.outputs.REPO_LOWERCASE }}:${{ github.event.release.tag_name }}
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
19 changes: 19 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Release Please

on:
push:
branches:
- main

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
steps:
- uses: googleapis/release-please-action@v4
with:
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
release-type: rust
2 changes: 1 addition & 1 deletion Cargo.lock

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

0 comments on commit 2475d0c

Please sign in to comment.