Skip to content
This repository has been archived by the owner on Jul 20, 2024. It is now read-only.

Commit

Permalink
first release
Browse files Browse the repository at this point in the history
  • Loading branch information
luongngocminh committed Dec 13, 2023
1 parent 74bc4bd commit dd02e0b
Show file tree
Hide file tree
Showing 37 changed files with 3,939 additions and 5,744 deletions.
31 changes: 20 additions & 11 deletions .github/actions/setup/action.yaml
Original file line number Diff line number Diff line change
@@ -1,23 +1,32 @@
name: 'Setup'
description: "Setups Node.js and npm to run GitHub Actions' jobs."
description: "Setups Node.js and pnpm to run GitHub Actions' jobs."
runs:
using: 'composite'
steps:
- name: 'Setup Node.js'
uses: 'actions/setup-node@v3'
uses: 'actions/setup-node@v4'
with:
node-version: '16.x'
cache: 'npm'
cache-dependency-path: '**/package-lock.json'
node-version: 16
registry-url: 'https://registry.npmjs.org'
- name: 'Setup pnpm'
uses: 'pnpm/action-setup@v2'
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- name: 'Keep npm cache for future workflows'
uses: 'actions/cache@v3'
- uses: actions/cache@v3
name: Setup pnpm cache
with:
key: "${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}"
path: '~/.npm'
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-node-
${{ runner.os }}-pnpm-store-
- name: 'Install dependencies'
run: 'npm ci'
run: 'pnpm i'
shell: 'bash'
28 changes: 17 additions & 11 deletions .github/workflows/continuous-integrations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,44 +3,50 @@ name: 'Continuous Integrations'
on:
push:
branches: ['main']
pull_request:
branches: ['main']

jobs:
lint:
name: 'Run ESLint and Prettier'
runs-on: 'ubuntu-latest'
steps:
- name: 'Checkout the repository'
uses: 'actions/checkout@v3'
uses: 'actions/checkout@v4'

- name: 'Setup Node.js and npm'
- name: 'Setup Node.js and pnpm'
uses: './.github/actions/setup'

- name: 'Execute the lint script'
run: 'npm run lint'

run: 'pnpm lint'

test:
name: 'Run unit tests with Jest'
name: 'Run unit tests with Jest and upload Coverage'
runs-on: 'ubuntu-latest'
steps:
- name: 'Checkout the repository'
uses: 'actions/checkout@v3'
uses: 'actions/checkout@v4'

- name: 'Setup Node.js and npm'
- name: 'Setup Node.js and pnpm'
uses: './.github/actions/setup'

- name: 'Execute the test script'
run: 'npm run test'
run: 'pnpm test'

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

bundle:
name: 'Bundle package with Rollup.js'
runs-on: 'ubuntu-latest'
steps:
- name: 'Checkout the repository'
uses: 'actions/checkout@v3'
uses: 'actions/checkout@v4'

- name: 'Setup Node.js and npm'
- name: 'Setup Node.js and pnpm'
uses: './.github/actions/setup'

- name: 'Execute the build script'
run: 'npm run build'
run: 'pnpm build'
52 changes: 52 additions & 0 deletions .github/workflows/publish-alpha.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
name: Publish Alpha

on:
release:
types: [published]

jobs:
setup:
if: 'github.event.release.prerelease'
permissions:
contents: none
runs-on: ubuntu-latest
outputs:
version: ${{ steps.trim.outputs.version }}
steps:
- id: trim
run: echo "version=${TAG:1}" >> $GITHUB_OUTPUT
env:
TAG: ${{ github.event.release.tag_name }}

publish:
runs-on: ubuntu-latest
needs: setup

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

- name: 'Setup Node.js and pnpm'
uses: './.github/actions/setup'

- name: 'Generate package.json'
run: npm run config:prerelease -- ${{ needs.setup.outputs.version }}

- name: 'Pack npm package'
run: pnpm pack

- name: 'Publish to npm'
run: pnpm publish --tag alpha --access public --no-git-checks
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Upload NPM package file
id: upload-npm-package-file
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
VERSION: ${{ needs.setup.outputs.version }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ format('8xff-atm0s-media-react-{0}.tgz', needs.setup.outputs.version) }}
asset_name: ${{ format('8xff-atm0s-media-react-{0}.tgz', needs.setup.outputs.version) }}
asset_content_type: application/gzip
55 changes: 55 additions & 0 deletions .github/workflows/publish-nightly.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Publish nightly

on:
workflow_dispatch: {}
repository_dispatch:
types: [publish-nightly]
schedule:
- cron: '0 0 * * *'

jobs:
check_date:
runs-on: ubuntu-latest
name: Check latest commit
outputs:
should_run: ${{ steps.should_run.outputs.should_run }}
steps:
- uses: actions/[email protected]
- name: Print Latest Commit
run: echo ${{ github.sha }}

- id: should_run
continue-on-error: true
name: Check if latest commit is less than a day
# if: ${{ github.event_name == 'schedule' }}
run: |
COMMIT_DATE=$(git show -s --format=%ci ${{ github.sha }})
COMMIT_DATE=$(date -d "$COMMIT_DATE" +%s)
NOW=$(date +%s)
DIFF=$(($NOW - $COMMIT_DATE))
echo "Commit date: $COMMIT_DATE"
echo "Now: $NOW"
echo "Diff: $DIFF"
if [ $DIFF -lt 86400 ]; then
echo "should_run=true" >> $GITHUB_OUTPUT
else
echo "should_run=false" >> $GITHUB_OUTPUT
fi
publish:
runs-on: ubuntu-latest
needs: check_date
if: ${{ needs.check_date.outputs.should_run == 'true' }}
steps:
- name: 'Checkout the repository'
uses: 'actions/checkout@v4'

- name: 'Setup Node.js and pnpm'
uses: './.github/actions/setup'

- name: 'Generate nightly package.json'
run: pnpm config:prerelease -- nightly

- run: pnpm publish --tag nightly --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
22 changes: 22 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Release Drafter

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened]

permissions:
contents: read

jobs:
update_release_draft:
permissions:
contents: write # for release-drafter/release-drafter to create a github release
pull-requests: write # for release-drafter/release-drafter to add label to PR
runs-on: ubuntu-latest
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
12 changes: 5 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,14 @@ yarn.lock
.yarnrc
.yarnrc.yaml

# pnpm's lockfile, workspace definitions and hooks.
# We're using npm, and it provides its lockfile and settings.
pnpm-lock.yaml
pnpm-workspace.yaml
pnpmfile.js
# npm's lockfile.
# We're using pnpm, and it provides its lockfile and settings.
package-lock.json

# Log files.
*.log
*.log.*

# Distribution directory.
# Dist
dist/
docs
docs/
Loading

0 comments on commit dd02e0b

Please sign in to comment.