-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: release for different gitea versions (#3)
- Loading branch information
Showing
10 changed files
with
73,702 additions
and
1,874 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,23 +2,27 @@ name: Release | |
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
tags: | ||
- '*' | ||
|
||
jobs: | ||
release: | ||
name: Release | ||
runs-on: ubuntu-latest | ||
env: | ||
GITEA_VERSION: ${{ github.ref_name }} | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- run: echo "Releasing version '${{github.ref_name}}' ..." | ||
|
||
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
node-version: '18' | ||
|
||
- name: Cache pnpm modules | ||
uses: actions/cache@v2 | ||
|
@@ -30,26 +34,20 @@ jobs: | |
- uses: pnpm/[email protected] | ||
with: | ||
version: 6 | ||
version: 7 | ||
run_install: true | ||
|
||
- name: Download Swagger Spec | ||
run: pnpm run download | ||
|
||
- name: Generate api | ||
run: pnpm run generate:api | ||
|
||
- name: Generate api docs | ||
run: pnpm run generate:docs | ||
- name: Generate api client & docs | ||
run: pnpm generate | ||
|
||
- name: Build | ||
run: pnpm run build | ||
run: pnpm build | ||
|
||
- name: Release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} | ||
run: pnpm run release | ||
run: pnpm publish --no-git-checks | ||
|
||
- name: Deploy 🚀 | ||
uses: JamesIves/[email protected] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,8 @@ jobs: | |
unit-tests: | ||
name: Unit tests | ||
runs-on: ubuntu-latest | ||
env: | ||
VERSION: latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
@@ -20,7 +22,7 @@ jobs: | |
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
node-version: '18' | ||
|
||
- name: Cache pnpm modules | ||
uses: actions/cache@v2 | ||
|
@@ -32,24 +34,22 @@ jobs: | |
- uses: pnpm/[email protected] | ||
with: | ||
version: 6 | ||
version: 7 | ||
run_install: true | ||
|
||
- name: Generate api | ||
run: pnpm generate:api | ||
- name: Generate client | ||
run: pnpm generate | ||
|
||
- name: Unit test | ||
env: | ||
TEST_GITEA_TOKEN: ${{ secrets.TEST_GITEA_TOKEN }} | ||
run: pnpm coverage | ||
|
||
# - uses: artiomtr/[email protected] | ||
# if: "github.event_name == 'pull_request'" | ||
# with: | ||
# github-token: ${{ secrets.GITHUB_TOKEN }} | ||
# skip-step: all | ||
|
||
typecheck: | ||
name: Typecheck | ||
runs-on: ubuntu-latest | ||
env: | ||
VERSION: latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
@@ -59,7 +59,7 @@ jobs: | |
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
node-version: '18' | ||
|
||
- name: Cache pnpm modules | ||
uses: actions/cache@v2 | ||
|
@@ -71,48 +71,20 @@ jobs: | |
- uses: pnpm/[email protected] | ||
with: | ||
version: 6 | ||
version: 7 | ||
run_install: true | ||
|
||
- name: Generate api | ||
run: pnpm generate:api | ||
- name: Generate client | ||
run: pnpm generate | ||
|
||
- name: Typecheck | ||
run: pnpm typecheck | ||
|
||
# lint: | ||
# name: Lint | ||
# runs-on: ubuntu-latest | ||
# steps: | ||
# - name: Checkout | ||
# uses: actions/checkout@v2 | ||
# with: | ||
# fetch-depth: 0 | ||
|
||
# - name: Setup Node.js | ||
# uses: actions/setup-node@v2 | ||
# with: | ||
# node-version: '14' | ||
|
||
# - name: Cache pnpm modules | ||
# uses: actions/cache@v2 | ||
# with: | ||
# path: ~/.pnpm-store | ||
# key: ${{ runner.os }}-${{ hashFiles('**/pnpm-lock.yaml') }} | ||
# restore-keys: | | ||
# ${{ runner.os }}- | ||
|
||
# - uses: pnpm/[email protected] | ||
# with: | ||
# version: 6 | ||
# run_install: true | ||
|
||
# - name: Lint | ||
# run: pnpm run lint | ||
|
||
check-format: | ||
name: Check format | ||
runs-on: ubuntu-latest | ||
env: | ||
VERSION: latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
@@ -122,7 +94,7 @@ jobs: | |
- name: Setup Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: '14' | ||
node-version: '18' | ||
|
||
- name: Cache pnpm modules | ||
uses: actions/cache@v2 | ||
|
@@ -134,7 +106,7 @@ jobs: | |
- uses: pnpm/[email protected] | ||
with: | ||
version: 6 | ||
version: 7 | ||
run_install: true | ||
|
||
- name: Check format | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { generateApi } from 'swagger-typescript-api'; | ||
import path from 'path'; | ||
import { exec as _exec } from 'child_process'; | ||
import fs from 'fs'; | ||
|
||
async function exec(cmd: string) { | ||
return await new Promise<string>((resolve) => { | ||
_exec(cmd, (err: any, stdout: any, stderr: any) => { | ||
if (err) { | ||
console.error(err); | ||
return; | ||
} | ||
console.log(stdout); | ||
resolve(stdout); | ||
}); | ||
}); | ||
} | ||
|
||
function getVersions(_version: string) { | ||
if (!_version) { | ||
throw new Error('version must be set'); | ||
} | ||
|
||
if (_version === 'latest') { | ||
const newestFile = fs.readdirSync(path.resolve(__dirname, '..', 'src', 'schemas')).sort().pop(); | ||
const giteaVersion = newestFile?.replace('v', '').replace('.json', ''); | ||
|
||
return { | ||
version: `${giteaVersion}.0`, | ||
giteaVersion, | ||
}; | ||
} | ||
|
||
const version = _version.replace(/^v/, ''); | ||
const [major, minor] = version.split('.'); | ||
const giteaVersion = `${major}.${minor}`; | ||
|
||
return { version, giteaVersion }; | ||
} | ||
|
||
async function run(_version: string) { | ||
const { version, giteaVersion } = getVersions(_version); | ||
|
||
console.log(`Generating gitea-js version "${version}" for Gitea "${giteaVersion}" ...`); | ||
|
||
await generateApi({ | ||
name: 'api.ts', | ||
output: path.resolve(__dirname, '..', 'src'), | ||
input: path.resolve(__dirname, '..', 'src', 'schemas', `v${giteaVersion}.json`), | ||
}); | ||
|
||
console.log(`Generating docs for ...`); | ||
|
||
await exec(`typedoc src/index.ts`); | ||
|
||
console.log(`Setting package.json version to "${version}" ...`); | ||
|
||
await exec(`sed -i 's/0.0.0/${version}/g' package.json`); | ||
|
||
console.log(`Done.`); | ||
} | ||
|
||
run(process.env.VERSION); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.