ci: 修改trigger为version触发 #1
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: Release_auto_update | |
on: | |
# release: | |
# types: | |
# - published | |
push: | |
tags: | |
- 'v*' | |
workflow_dispatch: | |
jobs: | |
build: | |
strategy: | |
matrix: | |
go-version: [1.20.x] | |
platform: [macOS-latest] | |
runs-on: ${{ matrix.platform }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install Go | |
if: success() | |
uses: actions/setup-go@v2 | |
with: | |
go-version: ${{ matrix.go-version }} | |
- name: Run unit tests | |
run: go test -v -race -cover -coverprofile coverage.txt -covermode=atomic ./... | |
- name: Parse Event | |
run: | | |
echo "tag=$(jq -r '.release.tag_name' "${GITHUB_EVENT_PATH}" | sed s/^v//)" >> $GITHUB_ENV | |
- name: Build and pack | |
run: | | |
# build package | |
GOOS=darwin GOARCH=amd64 go build -ldflags "-s -w -X github.com/91go/docs-alfred/cmd.EnabledAutoUpdate=true" -o exe_amd64 | |
GOOS=darwin GOARCH=arm64 go build -ldflags "-s -w -X github.com/91go/docs-alfred/cmd.EnabledAutoUpdate=true" -o exe_arm64 | |
lipo -create -output .workflow/exe exe_amd64 exe_arm64 | |
rm exe_amd64 | |
rm exe_arm64 | |
# pack | |
cd .workflow | |
plutil -replace version -string "${{ env.tag }}" info.plist | |
zip -r ../"docs-alfred_auto_update-${{ env.tag }}.alfredworkflow" . | |
cd .. | |
echo "artifact=$(echo "docs-alfred_auto_update-${{ env.tag }}.alfredworkflow")" >> $GITHUB_ENV | |
- uses: shogo82148/actions-upload-release-asset@v1 | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: "${{ env.artifact }}" |