Create Alfred Workflow #6
This file contains hidden or 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: Create Alfred Workflow | |
| on: | |
| push: | |
| tags: | |
| - "*" | |
| workflow_dispatch: | |
| inputs: | |
| dry_run: | |
| description: "Build and package only (no GitHub Release)." | |
| required: false | |
| default: "true" | |
| jobs: | |
| build: | |
| runs-on: macos-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: "1.22" | |
| - name: Build search binary | |
| run: | | |
| CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o search_amd64 . | |
| CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o search_arm64 . | |
| lipo -create -output search search_amd64 search_arm64 | |
| rm -f search_amd64 search_arm64 | |
| # Store version number without `v` | |
| - name: Write release version | |
| run: | | |
| TAG=${{ github.ref_name }} | |
| echo "VERSION=${TAG#v}" >> $GITHUB_ENV | |
| - name: Build Alfred workflow | |
| id: alfred_builder | |
| uses: com30n/build-alfred-workflow@v1 | |
| with: | |
| workflow_dir: . | |
| exclude_patterns: ".git/* .gitignore .github/* build-binary.sh go.mod *.go *_test.go resources/* search_amd64 search_arm64 target/*" | |
| custom_version: "${{ env.VERSION }}" | |
| - name: Create release | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| if: startsWith(github.ref, 'refs/tags/') && (github.event_name != 'workflow_dispatch' || github.event.inputs.dry_run != 'true') | |
| with: | |
| token: ${{ secrets.RELEASE_TOKEN }} | |
| files: ${{ steps.alfred_builder.outputs.workflow_file }} | |
| - name: Upload workflow artifact | |
| if: github.event_name == 'workflow_dispatch' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: alfred-workflow | |
| path: ${{ steps.alfred_builder.outputs.workflow_file }} |