From ad5abea9f5d9edb4f20be9e02ca3ee51a89d3a71 Mon Sep 17 00:00:00 2001 From: lonerapier Date: Wed, 30 Oct 2024 01:39:48 +0530 Subject: [PATCH] feat: download artifact and attach at release --- .github/workflows/artifacts.yaml | 58 +++++--------------------------- .github/workflows/release.yaml | 25 ++++++++++++-- 2 files changed, 31 insertions(+), 52 deletions(-) diff --git a/.github/workflows/artifacts.yaml b/.github/workflows/artifacts.yaml index 7e55e0d..2246014 100644 --- a/.github/workflows/artifacts.yaml +++ b/.github/workflows/artifacts.yaml @@ -5,46 +5,10 @@ concurrency: cancel-in-progress: true on: - release: - types: [published] pull_request: branches: [ "main" ] jobs: - check-version: - name: Check package.json version update - runs-on: ubuntu-latest - - steps: - - name: Checkout code - uses: actions/checkout@v4 - with: - fetch-depth: 2 # Fetch two commits to get the base branch - - - name: Fetch main branch - run: | - git fetch origin main - - - name: Compare package.json version with main - id: version_check - run: | - # Extract version from package.json in PR branch - PR_VERSION=$(jq -r .version package.json) - - # Extract version from package.json in main branch - MAIN_VERSION=$(git show origin/main:package.json | jq -r .version) - - echo "PR version: $PR_VERSION" - echo "Main version: $MAIN_VERSION" - - # Fail if versions match - if [ "$PR_VERSION" == "$MAIN_VERSION" ]; then - echo "Error: package.json version has not been updated in this PR." - exit 1 - else - echo "package.json version has been updated in this PR." - fi - build: runs-on: ubuntu-latest @@ -64,6 +28,10 @@ jobs: with: toolchain: nightly-2024-06-10 + - uses: Swatinem/rust-cache@v2 + with: + cache-on-failure: true + - name: Install Circom run: | CIRCOM_VERSION=2.1.9 @@ -111,7 +79,7 @@ jobs: - name: Create release artifacts run: | cd artifacts - zip -r ../circom-artifacts-v${VERSION}.zip ./* + zip -r ../circom-artifacts.zip ./* cd .. # Upload artifacts for PR @@ -119,16 +87,6 @@ jobs: if: github.event_name == 'pull_request' uses: actions/upload-artifact@v4 with: - name: circom-artifacts-v${{ env.VERSION }} - path: artifacts/ - retention-days: 5 - - # Add artifacts to existing release - - name: Upload Release Asset - if: github.event_name == 'release' - uses: softprops/action-gh-release@v1 - with: - files: circom-artifacts-v${{ env.VERSION }}.zip - tag_name: ${{ github.ref }} - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file + name: circom-artifacts + path: circom-artifacts.zip + retention-days: 5 \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 2606f20..100bb90 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -38,7 +38,7 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | npx semantic-release --dry-run - + release: name: Release runs-on: ubuntu-latest @@ -57,7 +57,28 @@ jobs: - name: Install dependencies run: npm ci + - name: Get Latest Successful build-circuits Run ID + id: get_run_id + env: + GH_TOKEN: ${{ github.token }} + run: | + # Fetch the latest successful run of the build-circuits workflow on main + response=$(gh api -X GET /repos/${{ github.repository }}/actions/workflows/artifacts.yaml/runs \ + -f status=success -q '.workflow_runs | map(select(.name == "build-circuits")) | .[0].id') + echo "run_id=${response}" >> $GITHUB_ENV + + - name: Download Build Artifacts + uses: actions/download-artifact@v4 + with: + name: circom-artifacts + path: . + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ env.run_id }} + - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: npx semantic-release \ No newline at end of file + run: | + npx semantic-release + RELEASE_TAG=$(git tag --list --contains HEAD | tail -1) + gh release upload $RELEASE_TAG "circom-artifacts.zip" \ No newline at end of file