-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from nitezs/dev
Dev
- Loading branch information
Showing
33 changed files
with
10,871 additions
and
10,617 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 |
---|---|---|
@@ -1,69 +1,66 @@ | ||
name: Build and Push to GHCR | ||
name: Build and Push Docker | ||
|
||
on: | ||
push: | ||
branches: | ||
- dev | ||
tags: | ||
- '*' | ||
- "*" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@v1 | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Set tag name | ||
id: set_tag | ||
run: | | ||
if [[ $GITHUB_REF == refs/heads/* ]]; then | ||
echo "::set-output name=tag::$(echo $GITHUB_REF | cut -d'/' -f3)" | ||
else | ||
echo "::set-output name=tag::${{ github.ref_name }}" | ||
fi | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v3 | ||
with: | ||
username: ${{ secrets.DOCKER_HUB_USERNAME }} | ||
password: ${{ secrets.DOCKER_HUB_PASSWORD }} | ||
|
||
- name: Check if triggered by tag | ||
id: check_tag | ||
- name: Docker meta | ||
id: meta | ||
uses: docker/metadata-action@v5 | ||
with: | ||
images: | | ||
${{ secrets.DOCKER_HUB_USERNAME }}/sub2clash | ||
ghcr.io/${{ github.repository }} | ||
- name: Prepare args | ||
id: prep | ||
run: | | ||
if [[ "${{ github.ref }}" == refs/tags/* ]]; then | ||
echo "::set-output name=triggered_by_tag::true" | ||
else | ||
echo "::set-output name=triggered_by_tag::false" | ||
if [[ "${{ github.event_name }}" == 'workflow_dispatch' ]]; then | ||
VERSION="${{ github.sha }}" | ||
fi | ||
if [[ "$GITHUB_REF" == 'refs/heads/dev' ]]; then | ||
VERSION="${{ github.sha }}" | ||
fi | ||
if [[ "$GITHUB_REF" == 'refs/tags/'* ]]; then | ||
VERSION=$TAG_NAME | ||
fi | ||
echo "version=$VERSION" >> $GITHUB_ENV | ||
- name: Build and push Docker image for dev branch | ||
if: steps.check_tag.outputs.triggered_by_tag == 'false' | ||
uses: docker/build-push-action@v2 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
build-args: | | ||
dev=true | ||
version=${{ github.sha }} | ||
push: true | ||
tags: ghcr.io/${{ github.repository }}:${{ steps.set_tag.outputs.tag }} | ||
- name: Set up Docker buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- name: Build and push Docker image for tags | ||
if: steps.check_tag.outputs.triggered_by_tag == 'true' | ||
uses: docker/build-push-action@v2 | ||
- name: Build and push Docker image to GHCR and Docker Hub | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
file: ./Dockerfile | ||
build-args: | | ||
dev=false | ||
version=${{ steps.set_tag.outputs.tag }} | ||
build-args: version=${{ env.version }} | ||
push: true | ||
tags: | | ||
ghcr.io/${{ github.repository }}:${{ steps.set_tag.outputs.tag }} | ||
ghcr.io/${{ github.repository }}:latest | ||
platforms: linux/amd64,linux/arm,linux/arm64 | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} |
This file was deleted.
Oops, something went wrong.
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,31 @@ | ||
name: Build and Release | ||
|
||
on: | ||
push: | ||
tags: | ||
- "*" | ||
workflow_dispatch: | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
packages: write | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Go | ||
uses: actions/setup-go@v4 | ||
with: | ||
go-version: 1.21.5 | ||
|
||
- name: Run goreleaser | ||
uses: goreleaser/goreleaser-action@v5 | ||
with: | ||
distribution: goreleaser | ||
version: latest | ||
args: release --rm-dist --clean | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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 |
---|---|---|
|
@@ -5,3 +5,4 @@ test | |
logs | ||
sub2clash.db | ||
.env | ||
.vscode/settings.json |
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 |
---|---|---|
@@ -1,17 +1,18 @@ | ||
#before: | ||
# hooks: | ||
# - go mod tidy | ||
project_name: sub2clash | ||
builds: | ||
- env: | ||
- CGO_ENABLED=0 | ||
goos: | ||
- linux | ||
- windows | ||
- linux | ||
- darwin | ||
goarch: | ||
- amd64 | ||
- arm64 | ||
- "386" | ||
ldflags: | ||
- -s -w -X sub2clash/config.Version={{ .Version }} | ||
no_unique_dist_dir: true | ||
binary: "{{ .ProjectName }}-{{ .Os }}-{{ .Arch }}" | ||
archives: | ||
- format: binary |
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 |
---|---|---|
@@ -1,37 +1,47 @@ | ||
# `/clash`, `/meta` | ||
# `GET /clash`, `GET /meta` | ||
|
||
获取 Clash/Clash.Meta 配置链接 | ||
|
||
| Query 参数 | 类型 | 是否必须 | 默认值 | 说明 | | ||
|--------------|--------|-------------------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| sub | string | sub/proxy 至少有一项存在 | - | 订阅链接,可以在链接结尾加上`#名称`,来给订阅中的节点加上统一前缀(可以输入多个,用 `,` 分隔) | | ||
| proxy | string | sub/proxy 至少有一项存在 | - | 节点分享链接(可以输入多个,用 `,` 分隔) | | ||
| refresh | bool | 否 | `false` | 强制刷新配置(默认缓存 5 分钟) | | ||
| template | string | 否 | - | 外部模板链接或内部模板名称 | | ||
| ruleProvider | string | 否 | - | 格式 `[Behavior,Url,Group,Prepend,Name],[Behavior,Url,Group,Prepend,Name]...`,其中 `Group` 是该规则集使用的策略组名,`Prepend` 为 bool 类型,如果为 `true` 规则将被添加到规则列表顶部,否则添加到规则列表底部(会调整到 MATCH 规则之前) | | ||
| rule | string | 否 | - | 格式 `[Rule,Prepend],[Rule,Prepend]...`,其中 `Prepend` 为 bool 类型,如果为 `true` 规则将被添加到规则列表顶部,否则添加到规则列表底部(会调整到 MATCH 规则之前) | | ||
| autoTest | bool | 否 | `false` | 国家策略组是否自动测速 | | ||
| lazy | bool | 否 | `false` | 自动测速是否启用 lazy | | ||
| sort | string | 否 | `nameasc` | 国家策略组排序策略,可选值 `nameasc`、`namedesc`、`sizeasc`、`sizedesc` | | ||
| replace | string | 否 | - | 通过正则表达式重命名节点,格式 `[<ReplaceKey>,<ReplaceTo>],[<ReplaceKey>,<ReplaceTo>]...` | | ||
| remove | string | 否 | - | 通过正则表达式删除节点 | | ||
| nodeList | bool | 否 | `false` | 只输出节点 | | ||
|
||
# `/short` | ||
| Query 参数 | 类型 | 是否必须 | 默认值 | 说明 | | ||
| ------------ | ------ | ------------------------ | --------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| sub | string | sub/proxy 至少有一项存在 | - | 订阅链接,可以在链接结尾加上`#名称`,来给订阅中的节点加上统一前缀(可以输入多个,用 `,` 分隔) | | ||
| proxy | string | sub/proxy 至少有一项存在 | - | 节点分享链接(可以输入多个,用 `,` 分隔) | | ||
| refresh | bool | 否 | `false` | 强制刷新配置(默认缓存 5 分钟) | | ||
| template | string | 否 | - | 外部模板链接或内部模板名称 | | ||
| ruleProvider | string | 否 | - | 格式 `[Behavior,Url,Group,Prepend,Name],[Behavior,Url,Group,Prepend,Name]...`,其中 `Group` 是该规则集使用的策略组名,`Prepend` 为 bool 类型,如果为 `true` 规则将被添加到规则列表顶部,否则添加到规则列表底部(会调整到 MATCH 规则之前) | | ||
| rule | string | 否 | - | 格式 `[Rule,Prepend],[Rule,Prepend]...`,其中 `Prepend` 为 bool 类型,如果为 `true` 规则将被添加到规则列表顶部,否则添加到规则列表底部(会调整到 MATCH 规则之前) | | ||
| autoTest | bool | 否 | `false` | 国家策略组是否自动测速 | | ||
| lazy | bool | 否 | `false` | 自动测速是否启用 lazy | | ||
| sort | string | 否 | `nameasc` | 国家策略组排序策略,可选值 `nameasc`、`namedesc`、`sizeasc`、`sizedesc` | | ||
| replace | string | 否 | - | 通过正则表达式重命名节点,格式 `[<ReplaceKey>,<ReplaceTo>],[<ReplaceKey>,<ReplaceTo>]...` | | ||
| remove | string | 否 | - | 通过正则表达式删除节点 | | ||
| nodeList | bool | 否 | `false` | 只输出节点 | | ||
|
||
# `POST /short` | ||
|
||
获取短链,Content-Type 为 `application/json` | ||
具体参考使用可以参考 [api\templates\index.html](api/static/index.html) | ||
|
||
| Body 参数 | 类型 | 是否必须 | 默认值 | 说明 | | ||
|----------|--------|------|-----|------------------| | ||
| url | string | 是 | - | 需要转换的 Query 参数部分 | | ||
| password | string | 否 | - | 短链密码 | | ||
| Body 参数 | 类型 | 是否必须 | 默认值 | 说明 | | ||
| --------- | ------ | -------- | ------ | ------------------------- | | ||
| url | string | 是 | - | 需要转换的 Query 参数部分 | | ||
| password | string | 否 | - | 短链密码 | | ||
|
||
# `/s/:hash` | ||
# `GET /s/:hash` | ||
|
||
短链跳转 | ||
`hash` 为动态路由参数,可以通过 `/short` 接口获取 | ||
|
||
| Query 参数 | 类型 | 是否必须 | 默认值 | 说明 | | ||
|----------|--------|------|-----|------| | ||
| password | string | 否 | - | 短链密码 | | ||
| Query 参数 | 类型 | 是否必须 | 默认值 | 说明 | | ||
| ---------- | ------ | -------- | ------ | -------- | | ||
| password | string | 否 | - | 短链密码 | | ||
|
||
# `PUT /short` | ||
|
||
更新短链,Content-Type 为 `application/json` | ||
|
||
| Body 参数 | 类型 | 是否必须 | 默认值 | 说明 | | ||
| --------- | ------ | -------- | ------ | ------------------------- | | ||
| url | string | 是 | - | 需要转换的 Query 参数部分 | | ||
| password | string | 否 | - | 短链密码 | | ||
| hash | string | 是 | - | 短链 hash | |
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.