Skip to content

Commit

Permalink
feat(jsr): Publish to JSR (#47)
Browse files Browse the repository at this point in the history
Stop using the dev branch to publish this project to JSR.
  • Loading branch information
5ouma authored Aug 29, 2024
1 parent 275c5af commit aa2def0
Show file tree
Hide file tree
Showing 13 changed files with 238 additions and 149 deletions.
32 changes: 1 addition & 31 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ I would recommend reading this guideline for a better development experience.
<br />

- [💬 Commit Message](#-commit-message)
- [🎋 Pull Requests Branch](#-pull-requests-branch)
- [❓ Pull Requests Title](#-pull-requests-title)
- [🪵 Commit Log](#-commit-log)

Expand All @@ -30,35 +29,6 @@ Body

<br />

## 🎋 Pull Requests Branch

I use the [`dev`] branch for the temporary merging.
When it's time to release, I'll merge the [`dev`] branch into the [`main`] branch.
<br />
For this reason, please fork the [`dev`] branch and open a PR to it.

[`main`]: https://github.com/5ouma/rproxy/tree/main
[`dev`]: https://github.com/5ouma/rproxy/tree/dev

```mermaid
flowchart LR
subgraph PR Branches
feature1
feature2
feature3
end
subgraph Origin Branches
dev
main
end
feature1 & feature2 & feature3 -- Squash Merge --> dev
dev -- Merge --> main
```

<br />

## ❓ Pull Requests Title

You don't need to add any prefixes like `feature` or `bug fix`
Expand All @@ -70,5 +40,5 @@ Please give a clear title.

## 🪵 Commit Log

I do squash merge to the dev branch to keep the commit history clean.
I do squash merge to the main branch to keep the commit history clean.
When merging your Pull Request, I'll add the Conventional Commits type and scope.
2 changes: 0 additions & 2 deletions .github/branch-switcher.yml

This file was deleted.

1 change: 0 additions & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ updates:
directory: /
schedule:
interval: daily
target-branch: dev
labels: []
3 changes: 0 additions & 3 deletions .github/workflows/deps-update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ jobs:
steps:
- name: 🚚 Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
ref: dev

- name: 🦕 Update Dependencies
uses: hasundue/molt-action@2042116c4f16e14c08c98130f1470c19c5cbfd2f # v1.0.2
with:
author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
base: dev
branch: deps-deno
commit-prefix: "chore(deps):"
labels:
43 changes: 43 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: 🚀 Release

on:
push:
branches:
- main
paths:
- deno.json

permissions:
contents: write
id-token: write

jobs:
Release:
runs-on: Ubuntu-Latest

steps:
- name: 🚚 Checkout Repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- name: 📦 Get the Package Version
uses: notiz-dev/github-action-json-property@a5a9c668b16513c737c3e1f8956772c99c73f6e8 # v0.2.0
id: version
with:
path: deno.json
prop_path: version

- name: 🔍 Detect the Version has Changed
id: version-has-changed
run: |
tag="$(git tag -l | sort -V | tail -n 1)"
if [[ "$tag" == "v${{ steps.version.outputs.prop }}" ]]; then
echo "stop=true" | tee -a "$GITHUB_OUTPUT"
fi
- name: 🚀 Rrelease a New Version
if: ${{ steps.version-has-changed.outputs.stop != 'true' }}
run: gh release create "v${{ steps.version.outputs.prop }}" --generate-notes

- name: ⬆️ Publish to JSR
if: ${{ steps.version-has-changed.outputs.stop != 'true' }}
run: npx jsr publish
1 change: 0 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches:
- main
- dev
paths:
- "**.ts"
- deno.lock
Expand Down
1 change: 0 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ ci:
chore(fix): Auto fixes from pre-commit.com hooks
For more information, see https://pre-commit.ci.
autoupdate_branch: dev
autoupdate_commit_msg: "chore(deps): Bump pre-commit hook"

repos:
Expand Down
48 changes: 22 additions & 26 deletions .github/README.md → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
**🚚 Deliver any files in the GitHub repository**

[![GitHub Release](https://img.shields.io/github/v/release/5ouma/reproxy?style=flat-square)](https://github.com/5ouma/reproxy/releases)
[![JSR](https://jsr.io/badges/@5ouma/reproxy?style=flat-square)](https://jsr.io/@5ouma/opmlreproxy)
<br />
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/5ouma/reproxy?style=flat-square)
![GitHub repo size](https://img.shields.io/github/repo-size/5ouma/reproxy?style=flat-square)
[![GitHub last commit](https://img.shields.io/github/last-commit/5ouma/reproxy?style=flat-square)](https://github.com/5ouma/reproxy/commit/HEAD)
[![GitHub commit activity](https://img.shields.io/github/commit-activity/m/5ouma/reproxy?style=flat-square)](https://github.com/5ouma/reproxy/commits/main)
<br />
[![Test](https://img.shields.io/github/actions/workflow/status/5ouma/reproxy/test.yml?label=test&style=flat-square)](https://github.com/5ouma/reproxy/actions/workflows/test.yml)
[![Release](https://img.shields.io/github/actions/workflow/status/5ouma/reproxy/release.yml?label=release&style=flat-square)](https://github.com/5ouma/reproxy/actions/workflows/release.yml)
[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/5ouma/reproxy/main.svg?style=flat-square)](https://results.pre-commit.ci/latest/github/5ouma/reproxy/main)
[![codecov](https://codecov.io/github/5ouma/reproxy/graph/badge.svg?token=OQB55KXJIL)](https://codecov.io/github/5ouma/reproxy)

Expand All @@ -34,35 +37,30 @@ To do this, simply add the ref name to the sub-directory.

## 🔧 Setup

You can host your file on [Deno Deploy](https://deno.com/deploy).

### 💪 Manual Deployment

1. Clone this repository

```sh
git clone https://github.com/5ouma/reproxy.git
```
### 💻 On Local

2. Copy the [`.env.tmpl`](../.env.tmpl) to `.env` and edit as you prefer
1. Copy the [`.env.tmpl`](./.env.tmpl) to `.env` and edit as you prefer

> [🌍 Environment Variables](#-environment-variables)
3. Install [Deno](https://deno.com) and [deployctl](https://docs.deno.com/deploy/manual/deployctl).

4. Deploy to Deno Deploy
2. Run this command

```sh
deployctl deploy --prod --env-file='.env'
deno run -A jsr:@5ouma/reproxy/serve
```

<br />

### ⚙️ Automatic Deployment
### 🦕 Use [Deno Deploy](https://deno.com/deploy)

1. [Fork this repository](https://github.com/5ouma/reproxy/fork)
1. [Create a new playground](https://dash.deno.com)

2. [Create a new project](https://dash.deno.com/new_project) with your forked repository
2. Replace the default code with this

```ts
import { app } from "jsr:@5ouma/reproxy";
Deno.serve(app.fetch);
```
3. Set the environment variables
(_Don't forget!!_)
Expand All @@ -79,13 +77,11 @@ You can host your file on [Deno Deploy](https://deno.com/deploy).
git clone https://github.com/5ouma/reproxy.git
```
2. Copy the [`.env.template`](../.env.template) to `.env` and edit as you prefer
2. Copy the [`.env.tmpl`](./.env.tmpl) to `.env` and edit as you prefer
> [🌍 Environment Variables](#-environment-variables)
3. Install [Deno](https://deno.com)
4. Run the [`server.ts`](../src/server.ts) via these task runners
3. Run the [`server.ts`](./src/server.ts) via these task runners
```sh
# For production
Expand All @@ -103,10 +99,10 @@ You can host your file on [Deno Deploy](https://deno.com/deploy).
| Name | Required |
| :----------------: | :------: |
| `REPOSITORY_OWNER` | true |
| `REPOSITORY_NAME` | true |
| `REPOSITORY_PATH` | true |
| [`GITHUB_TOKEN`] | false |
| `REPOSITORY_OWNER` | yes |
| `REPOSITORY_NAME` | yes |
| `REPOSITORY_PATH` | yes |
| [`GITHUB_TOKEN`] | no |
> [!NOTE]
> You need to add [`GITHUB_TOKEN`] if you want to:
Expand Down Expand Up @@ -134,5 +130,5 @@ You can host your file on [Deno Deploy](https://deno.com/deploy).
I happily welcome your contributions!
Before you contribute,
I would recommend reading [CONTRIBUTING.md](./CONTRIBUTING.md)
I would recommend reading [CONTRIBUTING.md](./.github/CONTRIBUTING.md)
for a better development experience.
22 changes: 12 additions & 10 deletions deno.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
{
"fmt": { "exclude": ["LICENSE", ".github/**/*.md"] },
"name": "@5ouma/reproxy",
"version": "1.0.0",
"exports": { ".": "./src/app.ts", "./serve": "./src/server.ts" },
"publish": {
"include": ["LICENSE", "README.md", "deno.json", "src/"],
"exclude": ["**/*.test.ts", "src/libs/test_utils.ts"]
},
"fmt": { "exclude": ["LICENSE", "README.md", ".github/**/*.md"] },
"tasks": {
"run": "deno run --env='.env' --allow-env='REPOSITORY_OWNER,REPOSITORY_NAME,REPOSITORY_PATH,GITHUB_TOKEN' --allow-net='0.0.0.0,api.github.com'",
"start": "deno task run ./src/server.ts",
"dev": "deno task run --watch ./src/server.ts",
"start": "deno task run src/server.ts",
"dev": "deno task run --watch src/server.ts",
"test": "deno test --allow-env='REPOSITORY_OWNER,REPOSITORY_NAME,REPOSITORY_PATH,GITHUB_TOKEN' --allow-net='0.0.0.0,api.github.com' --parallel --shuffle",
"cov": "deno task test --coverage && deno coverage --lcov > coverage.lcov"
},
"imports": {
"@hono/hono": "jsr:@hono/hono@4.5.8",
"@octokit/rest": "https://esm.sh/@octokit/rest@21.0.1",
"@std/assert": "jsr:@std/assert@1.0.2",
"@std/http": "jsr:@std/http@1.0.2",
"@std/path": "jsr:@std/path@1.0.2"
},
"deploy": {
"project": "reproxy",
"include": ["./deno.json", "./src/"],
"entrypoint": "./src/server.ts"
"@std/path": "jsr:@std/path@1.0.2",
"@octokit/rest": "npm:@octokit/rest@21.0.1"
}
}
Loading

0 comments on commit aa2def0

Please sign in to comment.