From 68e60ef35f3da18945455dfda4589e5d062fc1a3 Mon Sep 17 00:00:00 2001 From: Colin Roberts Date: Wed, 23 Oct 2024 18:32:08 -0600 Subject: [PATCH] use Semantic Release --- .github/workflows/artifacts.yaml | 23 +++++++-------------- .github/workflows/release.yaml | 34 ++++++++++++++++++++++++++++++++ .releaserc.js | 17 ++++++++++++++++ package.json | 8 ++++++++ 4 files changed, 66 insertions(+), 16 deletions(-) create mode 100644 .github/workflows/release.yaml create mode 100644 .releaserc.js diff --git a/.github/workflows/artifacts.yaml b/.github/workflows/artifacts.yaml index 0f5a8ed..8960024 100644 --- a/.github/workflows/artifacts.yaml +++ b/.github/workflows/artifacts.yaml @@ -1,12 +1,8 @@ name: build-circuits -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - on: - push: - branches: [ "main" ] + release: + types: [published] pull_request: branches: [ "main" ] @@ -45,7 +41,7 @@ jobs: - name: Install Node.js dependencies run: | - npm install + npm ci - name: Get package version id: package_version @@ -87,17 +83,12 @@ jobs: path: artifacts/ retention-days: 5 - # Create Release only on push to main - - name: Create Release - if: github.event_name == 'push' && github.ref == 'refs/heads/main' + # 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 - name: Circuit Artifacts v${{ env.VERSION }} - tag_name: v${{ env.VERSION }} - body: | - Automated release of compiled Circom circuits - Version: ${{ env.VERSION }} - Commit: ${{ github.sha }} + tag_name: ${{ github.ref }} env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..e237262 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,34 @@ +name: Release + +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + issues: write + +jobs: + release: + name: Release + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: "lts/*" + + - name: Install dependencies + run: npm ci + + - name: Release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: npx semantic-release \ No newline at end of file diff --git a/.releaserc.js b/.releaserc.js new file mode 100644 index 0000000..88523f8 --- /dev/null +++ b/.releaserc.js @@ -0,0 +1,17 @@ +// .releaserc.js +module.exports = { + branches: ['main'], + plugins: [ + '@semantic-release/commit-analyzer', + '@semantic-release/release-notes-generator', + '@semantic-release/npm', + '@semantic-release/github', + [ + '@semantic-release/git', + { + assets: ['package.json'], + message: 'chore(release): ${nextRelease.version} [skip ci]\n\n${nextRelease.notes}' + } + ] + ] +}; \ No newline at end of file diff --git a/package.json b/package.json index a0ef192..16b7e64 100644 --- a/package.json +++ b/package.json @@ -5,5 +5,13 @@ "dependencies": { "parser-attestor": "github:pluto/parser-attestor#b9feeeb240ddf867da85198de7d59e73cba4b008", "aes-proof": "github:pluto/aes-proof#1d08e13ea4f381649cdff83f56d93444008b6548" + }, + "devDependencies": { + "@semantic-release/commit-analyzer": "^11.1.0", + "@semantic-release/git": "^10.0.1", + "@semantic-release/github": "^9.2.6", + "@semantic-release/npm": "^11.0.2", + "@semantic-release/release-notes-generator": "^12.1.0", + "semantic-release": "^23.0.2" } } \ No newline at end of file