Skip to content

ci: use reusable workflows #337

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

Merged
merged 4 commits into from
Aug 17, 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
22 changes: 0 additions & 22 deletions .github/problemMatchers/eslint.json

This file was deleted.

17 changes: 0 additions & 17 deletions .github/problemMatchers/tsc.json

This file was deleted.

21 changes: 5 additions & 16 deletions .github/workflows/auto-deprecate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,8 @@ on:
jobs:
auto-deprecate:
name: NPM Auto Deprecate
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: yarn --immutable
- name: Deprecate versions
run: yarn npm-deprecate
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
uses: sapphiredev/.github/.github/workflows/reusable-yarn-job.yml@main
with:
script-name: npm-deprecate
secrets:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
20 changes: 4 additions & 16 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Code Scanning
name: Code scanning

on:
push:
Expand All @@ -11,18 +11,6 @@ on:
- cron: '30 1 * * 0'

jobs:
CodeQL:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v3

- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
codeql:
name: Analysis
uses: sapphiredev/.github/.github/workflows/reusable-codeql.yml@main
44 changes: 11 additions & 33 deletions .github/workflows/continuous-delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,51 +5,29 @@ on:
inputs:
prNumber:
description: The number of the PR that is being deployed
required: true
required: false
type: string
ref:
description: The branch that is being deployed. Should be a branch on the given repository
required: false
default: main
type: string
repository:
description: The {owner}/{repository} that is being deployed.
required: false
default: sapphiredev/cli
type: string
push:
branches:
- main

jobs:
Publish:
name: Publish Next to npm
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
with:
fetch-depth: 0
repository: ${{ github.event.inputs.repository || 'sapphiredev/cli' }}
ref: ${{ github.event.inputs.ref || 'main' }}
- name: Add TypeScript problem matcher
run: echo "::add-matcher::.github/problemMatchers/tsc.json"
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
registry-url: https://registry.yarnpkg.com/
- name: Install Dependencies
run: yarn --immutable
- name: Bump Version & Publish
run: |
# Resolve the tag to be used. "next" for push events, "pr-{prNumber}" for dispatch events.
TAG=$([[ ${{ github.event_name }} == 'push' ]] && echo 'next' || echo 'pr-${{ github.event.inputs.prNumber }}')

yarn config set npmAuthToken ${NODE_AUTH_TOKEN}
yarn config set npmPublishRegistry "https://registry.yarnpkg.com"

yarn bump --preid "${TAG}.$(git rev-parse --verify --short HEAD)" --skip-changelog

yarn npm publish --tag ${TAG}
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: sapphiredev/.github/.github/workflows/reusable-continuous-delivery.yml@main
with:
pr-number: ${{ github.event.inputs.prNumber }}
ref: ${{ github.event.inputs.ref }}
repository: ${{ github.event.inputs.repository }}
secrets:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
49 changes: 13 additions & 36 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Continuous Integration
name: CI

on:
push:
Expand All @@ -7,40 +7,17 @@ on:
pull_request:

jobs:
Linting:
linting:
name: Linting
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
- name: Add problem matcher
run: echo "::add-matcher::.github/problemMatchers/eslint.json"
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: yarn --immutable
- name: Run ESLint
run: yarn lint --fix=false
uses: sapphiredev/.github/.github/workflows/reusable-lint.yml@main

Building:
name: Compile source code
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
- name: Add problem matcher
run: echo "::add-matcher::.github/problemMatchers/tsc.json"
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
registry-url: https://registry.npmjs.org/
- name: Install Dependencies
run: yarn --immutable
- name: Build Code
run: yarn build
build:
name: Building
uses: sapphiredev/.github/.github/workflows/reusable-build.yml@main

sonar:
name: Sonar Analysis
uses: sapphiredev/.github/.github/workflows/reusable-sonar.yml@main
secrets:
SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
15 changes: 1 addition & 14 deletions .github/workflows/labelsync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,4 @@ on:

jobs:
label_sync:
name: Automatic Label Synchronization
runs-on: ubuntu-latest
steps:
- name: Checkout Project
uses: actions/checkout@v4
with:
sparse-checkout: .github/labels.yml
sparse-checkout-cone-mode: false
repository: 'sapphiredev/.github'
- name: Run Label Sync
uses: crazy-max/ghaction-github-labeler@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
yaml-file: .github/labels.yml
uses: sapphiredev/.github/.github/workflows/reusable-labelsync.yml@main
43 changes: 6 additions & 37 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,9 @@ on:
jobs:
PublishPackage:
name: Publish @sapphire/cli
runs-on: ubuntu-latest
if: github.repository_owner == 'sapphiredev'
steps:
- name: Checkout Project
uses: actions/checkout@v4
with:
fetch-depth: 0
ref: main
token: ${{ secrets.SKYRA_TOKEN }}
- name: Use Node.js v20
uses: actions/setup-node@v4
with:
node-version: 20
cache: yarn
registry-url: https://registry.yarnpkg.com/
- name: Install Dependencies
run: yarn --immutable
- name: Configure Git
run: |
git remote set-url origin "https://${GITHUB_TOKEN}:x-oauth-basic@github.com/${GITHUB_REPOSITORY}.git"
git config --local user.email "${GITHUB_EMAIL}"
git config --local user.name "${GITHUB_USER}"
env:
GITHUB_USER: github-actions[bot]
GITHUB_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Bump Versions and make release
run: yarn bump
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Publish to NPM
run: |
yarn config set npmAuthToken ${NODE_AUTH_TOKEN}
yarn config set npmPublishRegistry "https://registry.yarnpkg.com"
yarn npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
uses: sapphiredev/.github/.github/workflows/reusable-publish.yml@main
with:
project-name: '@sapphire/cli'
secrets:
NODE_AUTH_TOKEN: ${{ secrets.NPM_PUBLISH_TOKEN }}
SKYRA_TOKEN: ${{ secrets.SKYRA_TOKEN }}
26 changes: 0 additions & 26 deletions .github/workflows/release-crosspost.yml

This file was deleted.

4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@
"*.ts.sapphire": "typescript",
"*.json.sapphire": "json",
"*.yml.sapphire": "yaml"
},
"sonarlint.connectedMode.project": {
"connectionId": "https-sonarqube-sapphirejs-dev",
"projectKey": "sapphiredev_cli_3f02e75d-9123-4094-a35c-70aac6350330"
}
}
1 change: 1 addition & 0 deletions sonar-project.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
sonar.projectKey=sapphiredev_cli_3f02e75d-9123-4094-a35c-70aac6350330