From 1abb930107a48875aacca9da51bfdb0281415348 Mon Sep 17 00:00:00 2001 From: Rafael Cardenas Date: Tue, 17 Sep 2024 14:34:37 -0600 Subject: [PATCH 1/6] ci: upgrade upload-artifact --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a1066d6b4..06d9f82ca 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -273,14 +273,14 @@ jobs: # Separate uploads to prevent paths from being preserved - name: Upload cargo artifacts (Linux) if: matrix.os != 'windows-latest' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: chainhook-${{ env.SHORT_TARGET_NAME }} path: chainhook-${{ env.SHORT_TARGET_NAME }}.tar.gz - name: Upload cargo artifact (Windows) if: matrix.os == 'windows-latest' - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: chainhook-${{ env.SHORT_TARGET_NAME }} path: chainhook-${{ env.SHORT_TARGET_NAME }}.msi From d222d66d1accbf220988998f011bab5616186efd Mon Sep 17 00:00:00 2001 From: Rafael Cardenas Date: Tue, 17 Sep 2024 15:11:11 -0600 Subject: [PATCH 2/6] ci: semantic release --- .github/workflows/ci.yaml | 96 +++++++++++++++++---------------------- .releaserc | 17 ++++++- 2 files changed, 58 insertions(+), 55 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 06d9f82ca..3367f5bcf 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -15,40 +15,7 @@ concurrency: cancel-in-progress: true jobs: - - get_release_info: - name: Get Release Info - runs-on: ubuntu-latest - outputs: - tag: ${{ steps.new_release_tag.outputs.TAG }} - steps: - - name: Checkout - uses: actions/checkout@v4 - - - name: Get latest release - if: startsWith(github.ref, 'refs/heads/main') - id: release - uses: pozetroninc/github-action-get-latest-release@master - with: - repository: ${{ github.repository }} - excludes: prerelease, draft - - - name: Determine if release build - if: startsWith(github.ref, 'refs/heads/main') - id: new_release_tag - env: - LATEST_RELEASE: ${{ steps.release.outputs.release }} - run: | - CARGO_VERSION=v$(grep "version" components/chainhook-cli/Cargo.toml | head -n 1 | cut -d\" -f2) - if [[ "${CARGO_VERSION}" != "${LATEST_RELEASE}" ]]; then - echo "::set-output name=TAG::${CARGO_VERSION}" - echo "::warning::Will create release for version: ${CARGO_VERSION}" - else - echo "::warning::Will not create a release" - fi - test: - name: Generate test coverage runs-on: ubuntu-latest steps: - name: Checkout repository @@ -285,20 +252,47 @@ jobs: name: chainhook-${{ env.SHORT_TARGET_NAME }} path: chainhook-${{ env.SHORT_TARGET_NAME }}.msi - release: - name: Release + semantic-release: runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != '' needs: - test - dist_chainhook - - get_release_info + outputs: + new_release_version: ${{ steps.semantic.outputs.new_release_version }} + steps: + - uses: actions/checkout@v4 + with: + persist-credentials: false + + - name: Semantic Release + uses: cycjimmy/semantic-release-action@v4 + id: semantic + # Only run on non-PR events or only PRs that aren't from forks + if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SEMANTIC_RELEASE_PACKAGE: ${{ github.event.repository.name }} + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_CRATES_IO_API_KEY }} + with: + semantic_version: 19 + extra_plugins: | + @semantic-release/changelog@6.0.3 + @semantic-release/git@10.0.1 + @semantic-release/exec@6.0.3 + conventional-changelog-conventionalcommits@6.1.0 + + release: + runs-on: ubuntu-latest + if: needs.semantic-release.outputs.new_release_version != '' + needs: semantic-release permissions: actions: write contents: write steps: - name: Checkout uses: actions/checkout@v4 + with: + persist-credentials: false - name: Download pre-built dists uses: actions/download-artifact@v3 @@ -307,7 +301,7 @@ jobs: uses: ncipollo/release-action@v1 with: artifacts: "**/*.tar.gz,**/*.msi" - tag: ${{ needs.get_release_info.outputs.tag }} + tag: ${{ needs.semantic-release.outputs.new_release_version }} commit: ${{ env.GITHUB_SHA }} - name: Trigger pkg-version-bump workflow @@ -315,14 +309,11 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} event-type: released - client-payload: '{"tag": "${{ needs.get_release_info.outputs.tag }}"}' + client-payload: '{"tag": "${{ needs.semantic-release.outputs.new_release_version }}"}' build-publish: runs-on: ubuntu-latest - needs: - - test - - dist_chainhook - - get_release_info + needs: semantic-release outputs: docker_image_digest: ${{ steps.docker_push.outputs.digest }} strategy: @@ -340,11 +331,11 @@ jobs: persist-credentials: false - name: Checkout tag - if: needs.get_release_info.outputs.tag != '' + if: needs.semantic-release.outputs.new_release_version != '' uses: actions/checkout@v4 with: persist-credentials: false - ref: ${{ needs.get_release_info.outputs.tag }} + ref: ${{ needs.semantic-release.outputs.new_release_version }} - name: Set up Docker Buildx uses: docker/setup-buildx-action@v3 @@ -358,8 +349,8 @@ jobs: tags: | type=ref,event=branch type=ref,event=pr - type=semver,pattern={{version}},value=${{ needs.get_release_info.outputs.tag }},enable=${{ needs.get_release_info.outputs.tag != '' }} - type=semver,pattern={{major}}.{{minor}},value=${{ needs.get_release_info.outputs.tag }},enable=${{ needs.get_release_info.outputs.tag != '' }} + type=semver,pattern={{version}},value=${{ needs.semantic-release.outputs.new_release_version }},enable=${{ needs.semantic-release.outputs.new_release_version != '' }} + type=semver,pattern={{major}}.{{minor}},value=${{ needs.semantic-release.outputs.new_release_version }},enable=${{ needs.semantic-release.outputs.new_release_version != '' }} type=raw,value=latest,enable={{is_default_branch}} - name: Log in to DockerHub @@ -387,7 +378,7 @@ jobs: cache-from: type=gha cache-to: type=gha,mode=max # Only push if (there's a new release on main branch, or if building a non-main branch) and (Only run on non-PR events or only PRs that aren't from forks) - push: ${{ (github.ref != 'refs/heads/main' || needs.get_release_info.outputs.tag != '') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }} + push: ${{ (github.ref != 'refs/heads/main' || needs.semantic-release.outputs.new_release_version != '') && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) }} deploy-dev: runs-on: ubuntu-latest @@ -418,10 +409,9 @@ jobs: auto-approve-dev: runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != '' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) + if: startsWith(github.ref, 'refs/heads/main') && needs.semantic-release.outputs.new_release_version != '' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) needs: - build-publish - - get_release_info steps: - name: Approve pending deployments run: | @@ -462,11 +452,10 @@ jobs: auto-approve-stg: runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != '' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) + if: startsWith(github.ref, 'refs/heads/main') && needs.semantic-release.outputs.new_release_version != '' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) needs: - build-publish - deploy-dev - - get_release_info steps: - name: Approve pending deployments run: | @@ -484,8 +473,7 @@ jobs: needs: - build-publish - deploy-staging - - get_release_info - if: startsWith(github.ref, 'refs/heads/main') && needs.get_release_info.outputs.tag != '' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) + if: startsWith(github.ref, 'refs/heads/main') && needs.semantic-release.outputs.new_release_version != '' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository) env: DEPLOY_ENV: prd environment: diff --git a/.releaserc b/.releaserc index 7a1113cf0..9ef87a7c0 100644 --- a/.releaserc +++ b/.releaserc @@ -15,8 +15,23 @@ "preset": "conventionalcommits" } ], + [ + "@semantic-release/exec", + { + "prepareCmd": "sed -i -e '1h;2,$H;$!d;g' -e 's@name = \"chainhook\"\\nversion = \"[^\"]*\"@name = \"chainhook\"\\nversion = \"${nextRelease.version}\"@g' Cargo.toml Cargo.lock" + } + ], "@semantic-release/github", "@semantic-release/changelog", - "@semantic-release/git" + [ + "@semantic-release/git", + { + "assets": [ + "CHANGELOG.md", + "components/chainhook-cli/Cargo.toml", + "components/chainhook-cli/Cargo.lock" + ] + } + ] ] } From cad3b492e5d8d68985707a1450af9896cd596fa7 Mon Sep 17 00:00:00 2001 From: Rafael Cardenas Date: Tue, 17 Sep 2024 15:29:15 -0600 Subject: [PATCH 3/6] fix: remove old release step --- .github/workflows/ci.yaml | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3367f5bcf..b5a07758d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -57,8 +57,7 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} codecov_yml_path: .github/codecov.yml - dist_chainhook: - name: Build Chainhook Distributions + distributions: runs-on: ${{ matrix.os }} strategy: @@ -256,7 +255,7 @@ jobs: runs-on: ubuntu-latest needs: - test - - dist_chainhook + - distributions outputs: new_release_version: ${{ steps.semantic.outputs.new_release_version }} steps: @@ -264,6 +263,9 @@ jobs: with: persist-credentials: false + - name: Download pre-built dists + uses: actions/download-artifact@v4 + - name: Semantic Release uses: cycjimmy/semantic-release-action@v4 id: semantic @@ -281,35 +283,13 @@ jobs: @semantic-release/exec@6.0.3 conventional-changelog-conventionalcommits@6.1.0 - release: - runs-on: ubuntu-latest - if: needs.semantic-release.outputs.new_release_version != '' - needs: semantic-release - permissions: - actions: write - contents: write - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - persist-credentials: false - - - name: Download pre-built dists - uses: actions/download-artifact@v3 - - - name: Tag and Release - uses: ncipollo/release-action@v1 - with: - artifacts: "**/*.tar.gz,**/*.msi" - tag: ${{ needs.semantic-release.outputs.new_release_version }} - commit: ${{ env.GITHUB_SHA }} - - name: Trigger pkg-version-bump workflow uses: peter-evans/repository-dispatch@v1 + if: steps.semantic.outputs.new_release_version != '' with: token: ${{ secrets.GITHUB_TOKEN }} event-type: released - client-payload: '{"tag": "${{ needs.semantic-release.outputs.new_release_version }}"}' + client-payload: '{"tag": "${{ steps.semantic.outputs.new_release_version }}"}' build-publish: runs-on: ubuntu-latest From 5581831deda1ffa69af95e0c6d2b0ead32142d85 Mon Sep 17 00:00:00 2001 From: Rafael Cardenas Date: Tue, 17 Sep 2024 16:06:26 -0600 Subject: [PATCH 4/6] fix: upgrade cache --- .cargo/{config => config.toml} | 0 .github/workflows/ci.yaml | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) rename .cargo/{config => config.toml} (100%) diff --git a/.cargo/config b/.cargo/config.toml similarity index 100% rename from .cargo/config rename to .cargo/config.toml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index b5a07758d..9969f748e 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -32,7 +32,7 @@ jobs: run: sudo apt-get install -y redis-server - name: Cache cargo - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.cargo/bin/ @@ -111,7 +111,7 @@ jobs: run: echo "RUST_VERSION_HASH=$(rustc --version | sha256sum | awk '{print $1}')" >> $GITHUB_ENV - name: Cache cargo - uses: actions/cache@v3 + uses: actions/cache@v4 with: path: | ~/.cargo/ From 00fa2f0a09c0204b9d70726926f217833942cee1 Mon Sep 17 00:00:00 2001 From: Rafael Cardenas Date: Tue, 17 Sep 2024 16:29:35 -0600 Subject: [PATCH 5/6] ci: update download artifact --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9969f748e..dca076bd5 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -340,7 +340,7 @@ jobs: password: ${{ secrets.DOCKERHUB_PASSWORD }} - name: Download pre-built dist - uses: actions/download-artifact@v3 + uses: actions/download-artifact@v4 with: name: ${{ matrix.artifact }} From 64f7f197925210a6e411f7586e4318b3df4f7fdb Mon Sep 17 00:00:00 2001 From: Rafael Cardenas Date: Wed, 18 Sep 2024 09:32:09 -0600 Subject: [PATCH 6/6] chore: remove description --- .github/workflows/ci.yaml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index dca076bd5..0941707ca 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -300,9 +300,7 @@ jobs: fail-fast: false matrix: include: - - name: Chainhook - description: Chainhook is a reorg-aware indexing engine for the Stacks & Bitcoin blockchains. - image: ${{ github.repository }} + - image: ${{ github.repository }} artifact: chainhook-linux-x64-glibc dockerfile: dockerfiles/components/chainhook-node.dockerfile steps: