From 0dbdd2c68a76b09db6e36013deb515b994913e97 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Tue, 23 Jan 2024 16:41:57 +0100 Subject: [PATCH] ci: configure snapcraft (#3900) * ci: configure snapcraft * feedback * updates * updates --- .github/workflows/release-docker.yml | 29 +++++++++++++++++-------- .github/workflows/release-nightly.yml | 22 +++++++++++++++---- .github/workflows/snapcraft.yml | 4 ++++ Makefile | 8 +++++++ packaging/flatpak/com.ignite.Ignite.yml | 8 +++---- packaging/snap/snapcraft.yaml | 5 ++--- 6 files changed, 56 insertions(+), 20 deletions(-) diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index efc9215d3d..64c86edbf7 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -2,10 +2,9 @@ name: Release Docker Image on: release: - types: [ published ] - push: - branches: - - main + types: [published] + schedule: + - cron: "0 0 * * *" # every day at midnight concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -15,14 +14,27 @@ jobs: consecutiveness: runs-on: ubuntu-latest steps: - - uses: ignite/consecutive-workflow-action@main - with: - token: ${{ secrets.GITHUB_TOKEN }} + - uses: ignite/consecutive-workflow-action@main + with: + token: ${{ secrets.GITHUB_TOKEN }} + + check-latest-run: + runs-on: "ubuntu-latest" + steps: + - uses: octokit/request-action@v2.x + id: check_last_run + with: + route: GET /repos/${{github.repository}}/actions/workflows/release-docker.yml/runs?per_page=1&status=completed + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + outputs: + last_sha: ${{ fromJson(steps.check_last_run.outputs.data).workflow_runs[0].head_sha }} docker: name: Push Docker image to Docker Hub + if: needs.check-latest-run.outputs.last_sha != github.sha runs-on: ubuntu-latest - needs: [ consecutiveness ] + needs: [consecutiveness, check-latest-run] steps: - name: Check out the repo @@ -59,4 +71,3 @@ jobs: platforms: linux/amd64,linux/arm64 tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - diff --git a/.github/workflows/release-nightly.yml b/.github/workflows/release-nightly.yml index 18581f5a14..db554b2dbb 100644 --- a/.github/workflows/release-nightly.yml +++ b/.github/workflows/release-nightly.yml @@ -1,10 +1,9 @@ name: Release nightly on: + schedule: + - cron: "0 0 * * *" # every day at midnight workflow_dispatch: - push: - branches: - - main concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} @@ -18,9 +17,22 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} + check-latest-run: + runs-on: "ubuntu-latest" + steps: + - uses: octokit/request-action@v2.x + id: check_last_run + with: + route: GET /repos/${{github.repository}}/actions/workflows/release-nightly.yml/runs?per_page=1&status=completed + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + outputs: + last_sha: ${{ fromJson(steps.check_last_run.outputs.data).workflow_runs[0].head_sha }} + release-nightly: + if: needs.check-latest-run.outputs.last_sha != github.sha runs-on: ubuntu-latest - needs: [consecutiveness] + needs: [consecutiveness, check-latest-run] env: working-directory: go/src/github.com/ignite/cli @@ -51,7 +63,9 @@ jobs: prerelease: true releases-binaries: + if: needs.check-latest-run.outputs.last_sha != github.sha name: Release Go Binary + needs: [consecutiveness, check-latest-run] runs-on: ubuntu-latest strategy: matrix: diff --git a/.github/workflows/snapcraft.yml b/.github/workflows/snapcraft.yml index 6d16f32550..e67a5a8aff 100644 --- a/.github/workflows/snapcraft.yml +++ b/.github/workflows/snapcraft.yml @@ -23,6 +23,10 @@ jobs: with: fetch-depth: 0 + - name: Update snapcraft.yaml + run: | + make snapcraft.yaml version=${GITHUB_REF#refs/tags/} + - name: Build snap package uses: snapcore/action-build@v1 id: build-snap diff --git a/Makefile b/Makefile index 732651b6f8..f480d975c9 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,14 @@ build: @-mkdir -p $(BUILD_FOLDER) 2> /dev/null @go build $(BUILD_FLAGS) -o $(BUILD_FOLDER) ./... +## prepare snapcraft.yaml for release +snapcraft.yaml: + @sed -i 's/{{version}}/'$(version)'/' packaging/snap/snapcraft.yaml + +## prepare flatpak manifest for release +flatpak: + @sed -i 's/{{version}}/'$(version)'/' packaging/flatpak/com.ignite.Ignite.yml + ## mocks: generate mocks mocks: @echo Generating mocks diff --git a/packaging/flatpak/com.ignite.Ignite.yml b/packaging/flatpak/com.ignite.Ignite.yml index 875b63aa26..dcc831ad49 100644 --- a/packaging/flatpak/com.ignite.Ignite.yml +++ b/packaging/flatpak/com.ignite.Ignite.yml @@ -24,10 +24,10 @@ modules: build-commands: - $GOROOT/bin/go build -mod=readonly -o ignt ./ignite/cmd/ignite - install -Dm00755 ignt $FLATPAK_DEST/bin/ignite - #- install -Dm00644 packaging/flatpak/logo.svg $FLATPAK_DEST/share/icons/hicolor/scalable/apps/ignite.svg - #- install -Dm00644 packaging/flatpak/ignite.desktop $FLATPAK_DEST/share/applications/ignite.desktop - #- install -Dm00644 packaging/flatpak/ignite.metainfo.xml $FLATPAK_DEST/share/metainfo/ignite.metainfo.xml + - install -Dm00644 packaging/flatpak/logo.svg $FLATPAK_DEST/share/icons/hicolor/scalable/apps/ignite.svg + - install -Dm00644 packaging/flatpak/ignite.desktop $FLATPAK_DEST/share/applications/ignite.desktop + - install -Dm00644 packaging/flatpak/ignite.metainfo.xml $FLATPAK_DEST/share/metainfo/ignite.metainfo.xml sources: - type: git url: "https://github.com/ignite/cli.git" - tag: "v28.0.0" + tag: "v{{version}}" diff --git a/packaging/snap/snapcraft.yaml b/packaging/snap/snapcraft.yaml index 87822b1e9c..de53f3caf2 100644 --- a/packaging/snap/snapcraft.yaml +++ b/packaging/snap/snapcraft.yaml @@ -1,6 +1,6 @@ name: ignite base: core22 # the base snap is the execution environment for this snap -version: "28.0.0" +version: "{{version}}" summary: Build, launch, and maintain any crypto application with Ignite CLI # 79 char long summary description: | Ignite CLI offers everything you need to build, test, and launch your blockchain with a decentralized worldwide community. Ignite CLI is built on top of Cosmos SDK, the world's most popular blockchain framework. @@ -13,7 +13,7 @@ parts: ignite: plugin: go source: https://github.com/ignite/cli.git - source-tag: v28.0.0 + source-tag: v{{version}} source-subdir: ignite/cmd/ignite build-snaps: - go @@ -21,4 +21,3 @@ parts: apps: ignite: command: bin/ignite - plugs: [home, network, network-bind, removable-media]