-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update: dockerfile,workflow
- Loading branch information
Showing
19 changed files
with
629 additions
and
547 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: Build and push Docker image for tags | ||
if: steps.check_tag.outputs.triggered_by_tag == 'true' | ||
uses: docker/build-push-action@v2 | ||
- name: Set up Docker buildx | ||
uses: docker/setup-buildx-action@v3 | ||
|
||
- 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.prep.outputs.tags }} |
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
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,4 +1,4 @@ | ||
package controller | ||
package handler | ||
|
||
import ( | ||
"net/http" | ||
|
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,4 +1,4 @@ | ||
package controller | ||
package handler | ||
|
||
import ( | ||
"crypto/sha256" | ||
|
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,4 +1,4 @@ | ||
package controller | ||
package handler | ||
|
||
import ( | ||
_ "embed" | ||
|
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.