From 5e90e34f93a09399fd89472f6644b0c541d17f06 Mon Sep 17 00:00:00 2001 From: xjasonlyu Date: Fri, 16 Jul 2021 17:05:53 +0800 Subject: [PATCH] Chore: update actions --- .github/workflows/docker.yml | 22 +++++++-------- .github/workflows/go.yml | 36 +++++------------------- .github/workflows/release.yml | 53 +++++++++++++++++++++++++++++++++++ 3 files changed, 71 insertions(+), 40 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 003542d..cdf9dc2 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -3,12 +3,12 @@ name: Publish Docker Image on: push: branches: - - dev + - 'main' tags: - '*' paths-ignore: - - 'docs/**' - '**.md' + - 'docs/**' jobs: @@ -45,21 +45,21 @@ jobs: username: xjasonlyu password: ${{ secrets.CR_PAT }} - - name: Build and Push (dev) - if: github.ref == 'refs/heads/dev' + - name: Get Version + id: shell + run: | + echo ::set-output name=version::$(git describe --tags --abbrev=0) + + - name: Build and Push (nightly) + if: github.ref == 'refs/heads/main' uses: docker/build-push-action@v2 with: context: . push: true platforms: linux/amd64,linux/arm/v7,linux/arm64 tags: | - xjasonlyu/tun2socks:dev - ghcr.io/xjasonlyu/tun2socks:dev - - - name: Get Version - id: shell - run: | - echo ::set-output name=version::$(git describe --tags --abbrev=0) + xjasonlyu/tun2socks:nightly + ghcr.io/xjasonlyu/tun2socks:nightly - name: Build and Push (latest) if: startsWith(github.ref, 'refs/tags/') diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 762b79c..e093fa2 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -1,32 +1,24 @@ -name: Go +name: Go Static Check on: - pull_request: push: - branches: - - dev - tags: - - '*' - paths-ignore: - - 'docs/**' - - 'docker/**' - - '**.md' + pull_request: jobs: build: name: Build runs-on: ubuntu-latest steps: - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: 1.16.x - - name: Check out code into the Go module directory uses: actions/checkout@v2 with: fetch-depth: 0 + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.16.x + - name: Cache go module uses: actions/cache@v2 with: @@ -41,17 +33,3 @@ jobs: go vet ./... go install honnef.co/go/tools/cmd/staticcheck@latest staticcheck -- $(go list ./...) - - - name: Build - if: startsWith(github.ref, 'refs/tags/') - run: make -j releases - - - name: Upload Release - uses: softprops/action-gh-release@v1 - if: startsWith(github.ref, 'refs/tags/') - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - with: - files: build/* - draft: true - prerelease: false diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..58d4e4e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,53 @@ +name: Publish Go Releases + +on: + push: + branches: + - 'main' + tags: + - '*' + paths-ignore: + - '**.md' + - 'docs/**' + - 'docker/**' + +jobs: + build: + name: Build + runs-on: ubuntu-latest + steps: + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + with: + fetch-depth: 0 + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.16.x + + - name: Build + run: make -j releases + + - name: Upload Releases (nightly) + uses: softprops/action-gh-release@v1 + if: github.ref == 'refs/heads/main' + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: build/* + draft: false + prerelease: true + name: Nightly Build + tag_name: nightly + body: Automatically Released by Actions. + + - name: Upload Releases + uses: softprops/action-gh-release@v1 + if: startsWith(github.ref, 'refs/tags/') + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + files: build/* + draft: true + prerelease: false