add permissions #25
Workflow file for this run
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
name: Go | |
on: | |
push: | |
branches: ["main"] | |
tags: ["v*"] # 添加这行来监听标签推送 | |
pull_request: | |
branches: ["main"] | |
jobs: | |
build: | |
runs-on: ubuntu-20.04 | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up Go | |
uses: actions/setup-go@v4 | |
with: | |
go-version: "1.23" | |
- name: Build | |
run: go build -v -o output/go_webdav_client ./... | |
- name: Build arm64 | |
run: export GOOS=linux; export GOARCH=arm64; go build -v -o output/go_webdav_client_arm64 ./... | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: go_webdav_client-build | |
path: output/go_webdav_client* # 指定要上传的编译文件路径 | |
release: | |
runs-on: ubuntu-latest | |
needs: build | |
# 仅在推送以 "v" 开头的标签时运行 | |
if: startsWith(github.ref, 'refs/tags/v') | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: go_webdav_client-build | |
- name: Create GitHub Release | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: ${{ github.ref_name }} # 使用触发的标签名称 | |
name: auto release ${{ github.ref_name }} | |
body: "自动发布版本 ${{ github.ref_name }}" # 添加 release 描述 | |
files: go_webdav_client* # 将下载的二进制文件发布到 release 中 | |
draft: false | |
prerelease: false | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # 使用 GitHub 的 token 来授权发布 |