From f45adef2dcafe2a4a6afcad261c8caaf60d731ad Mon Sep 17 00:00:00 2001 From: ispong Date: Fri, 24 May 2024 11:49:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96github=E6=B5=81=E6=B0=B4?= =?UTF-8?q?=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/package.yml | 32 +++-------------- .github/workflows/release.yml | 65 +++++++++++++++++++++++++++++++++++ 2 files changed, 70 insertions(+), 27 deletions(-) create mode 100644 .github/workflows/release.yml diff --git a/.github/workflows/package.yml b/.github/workflows/package.yml index 46a5c88..cca8e20 100644 --- a/.github/workflows/package.yml +++ b/.github/workflows/package.yml @@ -1,15 +1,9 @@ name: release project on: - workflow_dispatch: - inputs: - admin_github_token: - description: '管理员github token' - required: true - type: string - -env: - ADMIN_GITHUB_TOKEN: ${{ inputs.admin_github_token }} + issues: + types: + - closed jobs: @@ -22,7 +16,7 @@ jobs: - name: Checkout isx-cli uses: actions/checkout@v4 with: - token: ${{ env.ADMIN_GITHUB_TOKEN }} + token: ${{ secrets.ADMIN_GITHUB_TOKEN }} repository: "isxcode/isx-cli" ref: 'main' @@ -41,7 +35,7 @@ jobs: with: go-version-file: './go.mod' - - name: install go modules + - name: Install go modules run: | go env -w GO111MODULE=auto go mod tidy @@ -59,22 +53,6 @@ jobs: - name: isx_darwin_amd64 run: CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ./target/isx_darwin_amd64 main.go -# - name: Upload file -# uses: actions/upload-artifact@v3 -# with: -# name: i-artifact -# path: | -# ./target/isx_windows_amd64.exe -# ./target/isx_linux_amd64 -# ./target/isx_darwin_arm64 -# ./target/isx_darwin_amd64 - -# - name: Push to github -# uses: softprops/action-gh-release@v1 -# with: -# files: target/* -# token: ${{ env.ADMIN_GITHUB_TOKEN }} - - name: Upload Package to Ali oss uses: chf007/aliyun-oss-upload-action@main env: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a6d4a2f --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,65 @@ +name: tag package + +on: + release: + types: [published] + +jobs: + + package: + + runs-on: ubuntu-latest + + steps: + + - name: Checkout isx-cli + uses: actions/checkout@v4 + + - name: Cache go modules + uses: actions/cache@v3 + with: + path: | + ~/.cache/go-build + ~/go/pkg/mod + key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} + restore-keys: | + ${{ runner.os }}-go- + + - name: Setup go env + uses: actions/setup-go@v4.1.0 + with: + go-version-file: './go.mod' + + - name: Install go modules + run: | + go env -w GO111MODULE=auto + go mod tidy + go install + + - name: isx_windows_amd64 + run: CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -o ./target/isx_windows_amd64.exe main.go + + - name: isx_linux_amd64 + run: CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o ./target/isx_linux_amd64 main.go + + - name: isx_darwin_arm64 + run: CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -o ./target/isx_darwin_arm64 main.go + + - name: isx_darwin_amd64 + run: CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o ./target/isx_darwin_amd64 main.go + + - name: Upload BinaryFile + uses: actions/upload-artifact@v3 + with: + name: i-artifact + path: | + ./target/isx_windows_amd64.exe + ./target/isx_linux_amd64 + ./target/isx_darwin_arm64 + ./target/isx_darwin_amd64 + + - name: Publish to github + uses: softprops/action-gh-release@v1 + with: + files: target/* + token: ${{ secrets.ADMIN_GITHUB_TOKEN }} \ No newline at end of file