Skip to content

Commit 79ac8ff

Browse files
committed
Revert "chore: remove old CI workflows"
This reverts commit 247a4fe.
1 parent 247a4fe commit 79ac8ff

2 files changed

Lines changed: 128 additions & 0 deletions

File tree

.github/workflows/build.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Build and Test
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Bun
17+
uses: oven-sh/setup-bun@v2
18+
with:
19+
bun-version: latest
20+
21+
- name: Install dependencies
22+
run: bun install
23+
24+
- name: Lint
25+
run: bun run lint
26+
27+
- name: Build
28+
run: bun run build
29+
30+
- name: Test with coverage
31+
run: bun run test:coverage
32+
33+
- name: Upload coverage to Codecov
34+
uses: codecov/codecov-action@v5
35+
with:
36+
token: ${{ secrets.CODECOV_TOKEN }}
37+
files: ./coverage/coverage-final.json
38+
fail_ci_if_error: false
39+
verbose: true

.github/workflows/release.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: Release
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build and Test"]
6+
types: [completed]
7+
branches: [main]
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
if: ${{ github.event.workflow_run.conclusion == 'success' }}
13+
permissions:
14+
contents: write
15+
id-token: write
16+
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
22+
- name: Get package version
23+
id: package
24+
run: echo "version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
25+
26+
- name: Check if tag exists
27+
id: tag_check
28+
run: |
29+
if git rev-parse "v${{ steps.package.outputs.version }}" >/dev/null 2>&1; then
30+
echo "exists=true" >> $GITHUB_OUTPUT
31+
else
32+
echo "exists=false" >> $GITHUB_OUTPUT
33+
fi
34+
35+
- name: Check if version exists on npm
36+
id: npm_check
37+
run: |
38+
if npm view transliteration@${{ steps.package.outputs.version }} version >/dev/null 2>&1; then
39+
echo "exists=true" >> $GITHUB_OUTPUT
40+
else
41+
echo "exists=false" >> $GITHUB_OUTPUT
42+
fi
43+
44+
- name: Setup Bun
45+
if: steps.npm_check.outputs.exists == 'false'
46+
uses: oven-sh/setup-bun@v2
47+
with:
48+
bun-version: latest
49+
50+
- name: Setup Node.js for npm publish
51+
if: steps.npm_check.outputs.exists == 'false'
52+
uses: actions/setup-node@v4
53+
with:
54+
node-version: '20'
55+
registry-url: 'https://registry.npmjs.org'
56+
57+
- name: Update npm for OIDC support
58+
if: steps.npm_check.outputs.exists == 'false'
59+
run: npm install -g npm@latest
60+
61+
- name: Install dependencies
62+
if: steps.npm_check.outputs.exists == 'false'
63+
run: bun install
64+
65+
- name: Build
66+
if: steps.npm_check.outputs.exists == 'false'
67+
run: bun run build
68+
69+
- name: Publish to npm
70+
if: steps.npm_check.outputs.exists == 'false'
71+
run: npm publish
72+
73+
- name: Create and push tag
74+
if: steps.tag_check.outputs.exists == 'false'
75+
run: |
76+
git config user.name "github-actions[bot]"
77+
git config user.email "github-actions[bot]@users.noreply.github.com"
78+
git tag -a "v${{ steps.package.outputs.version }}" -m "Release v${{ steps.package.outputs.version }}"
79+
git push origin "v${{ steps.package.outputs.version }}"
80+
81+
- name: Create GitHub Release
82+
if: steps.tag_check.outputs.exists == 'false'
83+
uses: softprops/action-gh-release@v2
84+
with:
85+
tag_name: v${{ steps.package.outputs.version }}
86+
name: v${{ steps.package.outputs.version }}
87+
generate_release_notes: true
88+
env:
89+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)