Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: download artifact and attach at release #13

Merged
merged 3 commits into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
74 changes: 31 additions & 43 deletions .github/workflows/artifacts.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ concurrency:
cancel-in-progress: true

on:
release:
types: [published]
pull_request:
branches: [ "main" ]

Expand All @@ -16,34 +14,30 @@ jobs:
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
- 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
Expand All @@ -64,6 +58,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
Expand Down Expand Up @@ -111,7 +109,7 @@ jobs:
- name: Create release artifacts
run: |
cd artifacts
zip -r ../circom-artifacts-v${VERSION}.zip ./*
zip -r ../circom-artifacts-v${{ env.VERSION }}.zip ./*
cd ..

# Upload artifacts for PR
Expand All @@ -120,15 +118,5 @@ jobs:
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 }}
path: circom-artifacts-v${{ env.VERSION }}.zip
retention-days: 5
60 changes: 33 additions & 27 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,17 @@ on:
push:
branches:
- main
pull_request:
branches:
- main

permissions:
contents: write
pull-requests: write
issues: write

jobs:
verify:
name: Verify semantic release
release:
name: Release
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -33,31 +30,40 @@ jobs:
- name: Install dependencies
run: npm ci

- name: Verify semantic release
- name: Get package version
id: package_version
run: |
VERSION=$(node -p "require('./package.json').version")
echo "VERSION=$VERSION" >> $GITHUB_ENV

- name: Get Latest Successful build-circuits Run ID
id: get_run_id
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ github.token }}
run: |
npx semantic-release --dry-run

release:
name: Release
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# 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: Setup Node.js
uses: actions/setup-node@v4
- name: Download Build Artifacts
uses: actions/download-artifact@v4
with:
node-version: "lts/*"
name: circom-artifacts-v${{ env.VERSION }}
path: .
github-token: ${{ secrets.GITHUB_TOKEN }}
run-id: ${{ env.run_id }}

- name: Install dependencies
run: npm ci

- name: Release
# Add artifacts to existing release
- name: Upload Release Asset
uses: softprops/action-gh-release@v2
with:
files: circom-artifacts-v${{ env.VERSION }}.zip
tag_name: v${{ env.VERSION }}
body: |
Automated release of compiled Circom circuits
Version: ${{ env.VERSION }}
Commit: ${{ github.sha }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: npx semantic-release
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 0 additions & 17 deletions .releaserc.js

This file was deleted.

Loading