Skip to content

Commit

Permalink
chore: setup the proj
Browse files Browse the repository at this point in the history
  • Loading branch information
guanbinrui committed Mar 5, 2024
1 parent 58364f7 commit 827f559
Show file tree
Hide file tree
Showing 24 changed files with 3,114 additions and 87 deletions.
17 changes: 17 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Pull Request

## Description

<!-- Provide a brief description of the changes introduced by this pull request -->

## Related Issue

Closes SW-0000

<!-- Find your issue from: https://mask.atlassian.net/jira/software/c/projects/FW/boards/33/backlog -->

## Checklist

- [ ] I have tested these changes locally.
- [ ] I have reviewed the code changes.
- [ ] I have added unit tests if applicable.
22 changes: 22 additions & 0 deletions .github/workflows/conventional-commits.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: "Conventional Commits"

on:
pull_request:
types:
- opened
- edited
- synchronize
branches:
- "!sync-submodule-changes"
- "!l10n_crowdin_action"

jobs:
main:
name: validate
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
wip: true
32 changes: 32 additions & 0 deletions .github/workflows/crowdin-download.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Crowdin Download

on:
schedule:
- cron: '0 0 * * *' # every day at 00:00 (midnight)
- cron: '0 12 * * *' # every day at 12:00 PM (noon)

# start via Actions tab in Github UI
workflow_dispatch:

jobs:
download-translations:
runs-on: ubuntu-latest

steps:

- name: Checkout
uses: actions/checkout@v3

- name: Download from Crowdin
uses: crowdin/github-action@v1
with:
upload_translations: false
download_translations: true
create_pull_request: true
pull_request_body: 'FW-0000'
pull_request_base_branch_name: 'main'
pull_request_labels: 'automated'
project_id: ${{ secrets.CROWDIN_PROJECT_ID }}
token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
28 changes: 28 additions & 0 deletions .github/workflows/crowdin-upload.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
name: Crowdin Upload

on:
push:
branches:
- main

# start via Actions tab in Github UI
workflow_dispatch:

jobs:
upload-translations:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v3

# all locales must be extracted before upload on the main branch
- name: Upload to Crowdin
uses: crowdin/github-action@v1
with:
upload_translations: true
download_translations: false
project_id: ${{ secrets.CROWDIN_PROJECT_ID }}
token: ${{ secrets.CROWDIN_PERSONAL_TOKEN }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31 changes: 31 additions & 0 deletions .github/workflows/cspell.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: CSpell

on:
push:

jobs:
spellcheck:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: 'true'

- name: Authenticate NPM
uses: DimensionDev/github-token-action@latest
with:
registry: true

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.9.0'

- uses: pnpm/action-setup@v2
- name: Install dependencies
run: pnpm install

- name: Run CSpell
run: npx cspell "**/*"
43 changes: 43 additions & 0 deletions .github/workflows/eslint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: ESLint

on:
push:
branches:
- '**'
- '!main'
- '!released'
jobs:
eslint:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: 'true'

- name: Authenticate NPM
uses: DimensionDev/github-token-action@latest
with:
registry: true

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.9.0'

- uses: pnpm/action-setup@v2
- name: Install dependencies
run: pnpm install

- name: Run ESLint
run: npx eslint --fix .

- name: Check for changes in src/*
id: check-changes
run: echo "::set-output name=changes::$(git diff --name-only -- 'src/*')"

- name: Commit changes if any
uses: EndBug/add-and-commit@v9
with:
message: 'chore: eslint'
27 changes: 27 additions & 0 deletions .github/workflows/jira-issue-key-checking.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: "Check Jira Issue Key"

on:
pull_request:
types:
- opened
- edited
- synchronize
branches:
- "!sync-submodule-changes"
- "!l10n_crowdin_action"
merge_group:
types: [checks_requested]


permissions:
contents: read

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: DimensionDev/jira-issue-key-checker@master
if: ${{ github.event.pull_request }}
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jira-prefix: 'SW'
44 changes: 44 additions & 0 deletions .github/workflows/lingui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Lingui

on:
push:
branches:
- '**'
- '!main'
- '!released'

jobs:
extract:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: 'true'

- name: Authenticate NPM
uses: DimensionDev/github-token-action@latest
with:
registry: true

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.9.0'

- uses: pnpm/action-setup@v2
- name: Install dependencies
run: pnpm install

- name: Run Lingui
run: npm run lingui

- name: Check for changes in src/locales/*.po
id: check-changes
run: echo "::set-output name=changes::$(git diff --name-only -- 'src/locales/*.po')"

- name: Commit changes if any
uses: EndBug/add-and-commit@v9
with:
message: 'chore: lingui extract'
45 changes: 45 additions & 0 deletions .github/workflows/prettier.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Prettier

on:
push:
branhces:
- '**'
- '!main'
- '!released'

jobs:
prettier:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2
with:
submodules: 'true'

- name: Authenticate NPM
uses: DimensionDev/github-token-action@latest
with:
registry: true

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '18.9.0'

- uses: pnpm/action-setup@v2
- name: Install dependencies
run: pnpm install

- name: Check code style with Prettier
run: npx prettier . -w

- name: Check for changes in src/*
id: check-changes
run: echo "::set-output name=changes::$(git diff --name-only -- 'src/*')"

- name: Commit changes if any
uses: EndBug/add-and-commit@v9
with:
message: 'chore: prettier'

70 changes: 70 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
name: Release

on:
workflow_dispatch:
inputs:
version:
description: 'The next version to release, e.g. 0.1.0'
required: true
type: string
release_kind:
description: 'Select the release kind: major, minor, or patch'
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch

jobs:
release:
runs-on: ubuntu-latest
steps:
- name: Validate version format
id: validate_version
run: |
if ! [[ "${{ inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Invalid version format. Please use Semantic Versioning (SemVer) format, e.g., 0.1.0"
exit 1
fi
- name: Checkout code
uses: actions/checkout@v2
with:
fetch-depth: 0
fetch-tags: true

- name: Check if version exists
id: check_version
run: |
if git rev-parse "v${{ inputs.version }}" >/dev/null 2>&1; then
echo "Version already exists. Aborting release."
exit 1
fi
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '14'

- name: Bump version
id: bump_version
run: |
npm version ${{ inputs.version }} --no-git-tag-version
- name: Commit version
run: |
git config --local user.email "[email protected]"
git config --local user.name "GitHub Action"
git add package.json
git commit -m "[Release] ${{ inputs.release_kind }} v${{ inputs.version }}"
- name: Tag version
run: |
git tag v${{ inputs.version }}
- name: Push version
run: |
git branch -f released
git push origin released:released --force --tags
Loading

0 comments on commit 827f559

Please sign in to comment.