Skip to content
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
37 changes: 37 additions & 0 deletions .github/actions/npm-publish/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 'npm-publish'
description: 'npm-publish is a github composite action publish npm package.'
inputs:
github-token:
description: 'Github Token'
required: true
default: ''
version:
description: 'Version to be published'
required: true
default: ''
npm-auth-token:
description: 'NPM auth token'
required: true
default: ''
path:
description: 'Path to the package'
required: true
default: ''
runs:
using: "composite"
steps:
- name: Node
uses: actions/setup-node@v3
- name: Print version
shell: bash
run: echo "New version ${{ inputs.version }}"
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact
- name: Setup NPM Registry
shell: bash
run: echo '//registry.npmjs.org/:_authToken=${{ inputs.npm-auth-token }}' > ~/.npmrc && npm config get registry && npm whoami
- name: Publish
shell: bash
run: npm publish ${{ inputs.path }}
164 changes: 119 additions & 45 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -1,81 +1,155 @@
name: Publish
name: Deploy

on:
push:
branches:
- master
- feature-*
- release-*
- hotfix-*

concurrency:
group: publish-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v3
- name: Node
uses: actions/setup-node@v3
- name: Cache
id: cache-nodemodules
uses: actions/cache@v3
with:
path: node_modules
key: packages-${{ hashFiles('yarn.lock') }}
restore-keys: |
packages-
- name: Install
run: yarn install
- name: Lint
run: yarn lint
- name: Build
run: yarn build
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
with:
name: build-artifact
path: ./

should-release:
needs: [build]
name: Should Release
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4
- name: Node
uses: actions/setup-node@v4
with:
node-version: 20
uses: actions/setup-node@v3
- name: Deps
run: npm i -g semver
- name: Run should-release
run: node ./scripts/should-release.js
shell: bash
run: scripts/should-release.sh package.json
- name: Current Version
id: current-version
run: echo 'CURRENT_VERSION='$(node -p -e "require('./package.json').version") >> $GITHUB_OUTPUT
run: echo 'current_version='$(node -p -e "require('./package.json').version") >> $GITHUB_OUTPUT
- name: Check Skip Release
id: skip-release
run: echo 'SKIP='$(cat .skip-release) >> $GITHUB_OUTPUT
run: echo 'skip='$(cat .skip-release) >> $GITHUB_OUTPUT
outputs:
SKIP: ${{ steps.skip-release.outputs.SKIP }}
CURRENT_VERSION: ${{ steps.current-version.outputs.CURRENT_VERSION }}
publish:
skip: ${{ steps.skip-release.outputs.skip }}
current_version: ${{ steps.current-version.outputs.current_version }}

release-candidate:
needs: [should-release]
if: needs.should-release.outputs.SKIP != 'true'
if: github.ref != 'refs/heads/master' && (startsWith(github.ref, 'refs/heads/feature-') || startsWith(github.ref, 'refs/heads/hotfix-') || startsWith(github.ref, 'refs/heads/release-'))
name: Release Candidate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download Build Artifact
uses: actions/download-artifact@v4
with:
name: build-artifact
path: ./
- name: Update package.json with RC version
if: ${{ needs.should-release.outputs.skip != 'true' }}
run: scripts/rc.sh package.json
- name: Upload Updated Artifact
if: ${{ needs.should-release.outputs.skip != 'true' }}
uses: actions/upload-artifact@v4
with:
name: build-artifact
path: ./
overwrite: true

publish:
needs: [should-release, release-candidate]
if: github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/hotfix-') || startsWith(github.ref, 'refs/heads/release-')
name: Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- id: npm-publish
if: ${{ needs.should-release.outputs.skip != 'true' }}
uses: ./.github/actions/npm-publish
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
version: ${{ needs.should-release.outputs.current_version }}
npm-auth-token: ${{ secrets.NPM_AUTH_TOKEN }}
path: .

create-tag:
needs: [publish]
if: github.ref == 'refs/heads/master'
name: Create Tag
runs-on: ubuntu-latest
steps:
- name: Clone
uses: actions/checkout@v4
- name: Node
uses: actions/setup-node@v4
with:
node-version: 20
- name: Cache Yarn
id: cache-nodemodules
uses: actions/cache@v4
fetch-depth: 0
- name: Semver
id: semver
uses: luanlmd/semver-composite-action@v1.0.0
with:
path: node_modules
key: packages-${{ hashFiles('yarn.lock') }}
restore-keys: |
packages-
- name: Yarn
if: steps.cache-nodemodules.outputs.cache-hit != 'true'
run: yarn install --immutable
- name: Setup NPM Registry
run: echo '//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}' > ~/.npmrc && npm config get registry && npm whoami
- name: Build
run: npm run build
- name: Publish
run: npm publish
- name: Check Skip Release
id: skip-release
run: echo 'SKIP='$(cat .skip-release) >> $GITHUB_OUTPUT
repo-path: ${{ github.workspace }}
- name: Create tag
uses: actions/github-script@v7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git tag ${{ steps.semver.outputs.version }}
git push --tags

notify:
needs: [build, should-release, release-candidate, publish, create-tag]
if: always()
name: Notify
runs-on: ubuntu-latest
steps:
- name: Discord Message on Success
if: ${{ needs.build.result != 'failure' && needs.should-release.result != 'failure' && needs.publish.result != 'failure' && needs.create-tag.result != 'failure'}}
uses: vitorvmrs/discord-send-embed@0f0cb61f7ed052734cc11765a5b2c5d0a5c3d9c2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/v${{ needs.should-release.outputs.CURRENT_VERSION }}",
sha: context.sha
})
outputs:
SKIP: ${{ steps.skip-release.outputs.SKIP }}
webhook-url: ${{ secrets.PI_DISCORD_WEBHOOK }}
title: "${{ github.repository }}/${{ github.ref_name }}"
url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
description: "🫡 DEPLOYED / Linterzinhiúu =]"
color: 65280
footer-text: "${{ github.sha }} - ${{ github.event.head_commit.message }}"
- name: Discord Message on Failure
if: ${{ needs.build.result == 'failure' || needs.should-release.result == 'failure' || needs.publish.result == 'failure' || needs.create-tag.result == 'failure' }}
uses: vitorvmrs/discord-send-embed@0f0cb61f7ed052734cc11765a5b2c5d0a5c3d9c2
with:
webhook-url: ${{ secrets.PI_DISCORD_WEBHOOK }}
title: "${{ github.repository }}/${{ github.ref_name }}"
url: "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
description: "❌ FAILED / Deu ruim =["
color: 16711680
footer-text: "${{ github.sha }} - ${{ github.event.head_commit.message }}"

17 changes: 1 addition & 16 deletions .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,16 +1 @@
module.exports = {
singleQuote: true,
jsxSingleQuote: true,
quoteProps: 'consistent',
trailingComma: 'none',
useTabs: false,
tabWidth: 2,
bracketSpacing: true,
bracketSameLine: false,
arrowParens: 'avoid',
endOfLine: 'auto',
printWidth: 120,
semi: true,
plugins: ['prettier-plugin-tailwindcss'],
tailwindFunctions: ['tw', 'clsx']
};
module.exports = require('./prettierrc');
2 changes: 1 addition & 1 deletion ignores.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const parse = require('parse-gitignore');

module.exports = function gitignore(...extra) {
const files = globSync('./**/.gitignore');
const ignores = [];
const ignores = ['dist/**', 'build/**', '.turbo/**', 'node_modules/**'];

for (const file of files) {
let content = '';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@eduzz/eslint-config",
"private": false,
"version": "2.5.5",
"version": "2.5.6",
"keywords": [
"eduzz",
"eslint"
Expand Down
33 changes: 33 additions & 0 deletions prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const path = require('path');

const config = {
singleQuote: true,
jsxSingleQuote: true,
quoteProps: 'consistent',
trailingComma: 'none',
useTabs: false,
tabWidth: 2,
bracketSpacing: true,
bracketSameLine: false,
arrowParens: 'avoid',
endOfLine: 'auto',
printWidth: 120,
semi: true,
tailwindFunctions: ['tw', 'clsx']
};

try {
require.resolve('prettier-plugin-tailwindcss', {
paths: [path.dirname(require.resolve('@eduzz/eslint-config/package.json'))]
});

config.plugins = [
require.resolve('prettier-plugin-tailwindcss', {
paths: [path.dirname(require.resolve('@eduzz/eslint-config/package.json'))]
})
];
} catch (error) {
console.info('prettier-plugin-tailwindcss not found, Tailwind formatting disabled');
}

module.exports = config;
24 changes: 24 additions & 0 deletions scripts/rc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash

set -e

PACKAGE_JSON=$1

if [ -z "$PACKAGE_JSON" ]; then
echo "Usage: $0 <package-json-path>"
exit 1
fi

VERSION=$(jq -r .version "$PACKAGE_JSON")
PACKAGE_NAME=$(jq -r .name "$PACKAGE_JSON")
BASE_VERSION=$(echo "$VERSION" | grep -o "^[0-9]\+\.[0-9]\+\.[0-9]\+")

RC_VERSION=$(npm view "$PACKAGE_NAME" versions --json | jq -r '.[]' | grep "${BASE_VERSION}-rc" | sort -V | tail -1 | awk -F'-rc.' '{print $1"-rc."($2+1)}')

if [ -z "$RC_VERSION" ]; then
RC_VERSION="${VERSION}-rc.0"
fi

jq --arg version "$RC_VERSION" '.version = $version' "$PACKAGE_JSON" > temp.json && mv temp.json "$PACKAGE_JSON"

echo "Updated version to: $RC_VERSION"
51 changes: 0 additions & 51 deletions scripts/should-release.js

This file was deleted.

Loading