From 2475d0c5ffd9aafae3d7ae6e6be8ab41ce7bdff0 Mon Sep 17 00:00:00 2001 From: Mike Date: Wed, 11 Dec 2024 22:12:18 -0600 Subject: [PATCH] fix: automated release workflow --- .../{docker-build.yml => release-build.yml} | 68 ++++--------------- .github/workflows/release-please.yml | 19 ++++++ Cargo.lock | 2 +- 3 files changed, 32 insertions(+), 57 deletions(-) rename .github/workflows/{docker-build.yml => release-build.yml} (61%) create mode 100644 .github/workflows/release-please.yml diff --git a/.github/workflows/docker-build.yml b/.github/workflows/release-build.yml similarity index 61% rename from .github/workflows/docker-build.yml rename to .github/workflows/release-build.yml index d842056..a5a9c6d 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/release-build.yml @@ -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: @@ -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 @@ -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: @@ -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 diff --git a/.github/workflows/release-please.yml b/.github/workflows/release-please.yml new file mode 100644 index 0000000..f4d4119 --- /dev/null +++ b/.github/workflows/release-please.yml @@ -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 diff --git a/Cargo.lock b/Cargo.lock index c6ba676..4fd4574 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -335,7 +335,7 @@ checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381" [[package]] name = "ovos_messagebus" -version = "0.3.1" +version = "0.3.3" dependencies = [ "EventEmitter", "futures-util",