From 383e3db435f569a423aede2f816d8733cf0510c8 Mon Sep 17 00:00:00 2001 From: Mohamed Elmoslemany <117270519+mo-c4t@users.noreply.github.com> Date: Mon, 19 Aug 2024 12:16:15 +0200 Subject: [PATCH] Release artifacts (#22) push docker image only when a release is published build camino-messenger-bot when a release is published and upload it as asset --- .github/workflows/docker.yml | 12 +++++++---- .github/workflows/release.yml | 40 +++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+), 4 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 6e6aaa9b..4b03205c 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -1,8 +1,8 @@ name: Publish Docker image on: - push: - branches: [c4t] + release: + types: [published] jobs: push_to_dockerhub: @@ -10,8 +10,12 @@ jobs: runs-on: ubuntu-latest steps: - - name: Check out the repo + - name: Checkout uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: true + ref: ${{ github.event.release.tag }} - name: Log in to Docker Hub uses: docker/login-action@v3 @@ -26,4 +30,4 @@ jobs: push: true tags: | c4tplatform/camino-messenger-bot:latest - c4tplatform/camino-messenger-bot:${{ github.sha }} \ No newline at end of file + c4tplatform/camino-messenger-bot:${{ github.event.release.tag }} \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 00000000..1aed7798 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,40 @@ +name: Publish Release Artifcats + +on: + release: + types: [published] + +permissions: + contents: write + +jobs: + release: + name: Publish Artifcats + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + submodules: true + ref: ${{ github.event.release.tag }} + + - uses: actions/setup-go@v5 + with: + go-version: '1.20' + + - name: Install libolm + run: sudo apt update && sudo apt-get install -y libolm-dev + + - name: Build + run: ./scripts/build.sh + + - name: upload release assets + run: | + cp ./build/bot ./camino-messenger-bot + tar -zcvf camino-messenger-bot-linux-amd64-${{ github.event.release.tag }}.tar.gz ./camino-messenger-bot + gh release upload ${{ github.event.release.tag }} camino-messenger-bot-linux-amd64-${{ github.event.release.tag }}.tar.gz + env: + GITHUB_TOKEN: ${{ github.TOKEN }} + shell: bash +