Skip to content

Commit

Permalink
Add common setup action
Browse files Browse the repository at this point in the history
  • Loading branch information
nitaliano committed Nov 21, 2024
1 parent 0904573 commit 9100af2
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 21 deletions.
25 changes: 25 additions & 0 deletions .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Setup
runs:
using: composite
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- uses: pnpm/action-setup@v2

- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
registry-url: https://registry.npmjs.org
cache: pnpm

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt

- name: pnpm install node modules
run: pnpm i --frozen-lockfile
shell: bash
23 changes: 2 additions & 21 deletions .github/workflows/release-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,8 @@ jobs:
if: github.repository == 'ethereum-optimism/super-cli'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
fetch-depth: 0

- uses: pnpm/action-setup@v2

- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
registry-url: https://registry.npmjs.org
cache: pnpm

- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt

- name: pnpm install node modules
run: pnpm i --frozen-lockfile
shell: bash
- name: Setup
uses: ./.github/actions/setup

- name: Set deployment token
run: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Release and version

on:
workflow_dispatch:
push:
branches:
- main

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
publish-release:
name: Release
runs-on: ubuntu-latest
if: github.repository == 'ethereum-optimism/super-cli'
permissions:
contents: write
pull-requests: write
id-token: write
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: "main"

- name: Setup
uses: ./.github/actions/setup

- name: Check if NPM_TOKEN is set
id: check_token
run: |
if [ -z "${{ secrets.NPM_TOKEN }}" ]; then
echo "NPM_TOKEN is not set. Is it set it in your repository secrets?"
exit 1
fi
shell: bash

- name: Set deployment token
run: npm config set '//registry.npmjs.org/:_authToken' "${NPM_TOKEN}"
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Verify NPM Token is valid
run: npm whoami

- name: Publish To NPM or Create Release Pull Request
uses: changesets/action@v1
id: changesets
with:
createGithubReleases: false
publish: pnpm release:publish
version: pnpm release:version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

0 comments on commit 9100af2

Please sign in to comment.