@@ -40,65 +40,89 @@ jobs:
4040 version : " ~> v2"
4141 install-only : true
4242
43- - name : GoReleaser (release + brew)
44- if : ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN != '' }}
43+ - name : GoReleaser release
4544 env :
4645 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4746 HOMEBREW_TAP_GITHUB_TOKEN : ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
48- run : goreleaser release --clean --config .goreleaser.yaml
49-
50- - name : GoReleaser (release only, skip brew)
51- if : ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN == '' }}
52- env :
53- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
54- run : goreleaser release --clean --config .goreleaser.yaml --skip=brew
47+ run : |
48+ if [ -n "$HOMEBREW_TAP_GITHUB_TOKEN" ]; then
49+ goreleaser release --clean --config .goreleaser.yaml
50+ else
51+ goreleaser release --clean --config .goreleaser.yaml --skip=brew
52+ fi
5553
5654 npm :
5755 runs-on : ubuntu-latest
5856 needs : goreleaser
59- if : ${{ secrets.NPM_TOKEN != ' ' }}
57+ if : ${{ startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch ' }}
6058 defaults :
6159 run :
6260 working-directory : switcher/npm
6361 steps :
62+ - name : Decide npm publish
63+ id : npm_gate
64+ env :
65+ NPM_TOKEN : ${{ secrets.NPM_TOKEN }}
66+ run : |
67+ if [ -n "$NPM_TOKEN" ]; then
68+ echo "publish=true" >> "$GITHUB_OUTPUT"
69+ else
70+ echo "publish=false" >> "$GITHUB_OUTPUT"
71+ fi
72+
6473 - name : Checkout
74+ if : ${{ steps.npm_gate.outputs.publish == 'true' }}
6575 uses : actions/checkout@v4
6676
6777 - name : Setup Node
78+ if : ${{ steps.npm_gate.outputs.publish == 'true' }}
6879 uses : actions/setup-node@v4
6980 with :
7081 node-version : " 20"
7182 registry-url : " https://registry.npmjs.org"
7283
7384 - name : Sync package version from tag
74- if : ${{ startsWith(github.ref, 'refs/tags/v') }}
85+ if : ${{ steps.npm_gate.outputs.publish == 'true' && startsWith(github.ref, 'refs/tags/v') }}
7586 run : npm version "${GITHUB_REF_NAME#v}" --no-git-tag-version
7687
7788 - name : Sync package version from input
78- if : ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' }}
89+ if : ${{ steps.npm_gate.outputs.publish == 'true' && github.event_name == 'workflow_dispatch' && github.event.inputs.version != '' }}
7990 run : npm version "${{ github.event.inputs.version }}" --no-git-tag-version
8091
8192 - name : Publish npm package
93+ if : ${{ steps.npm_gate.outputs.publish == 'true' }}
8294 env :
8395 NODE_AUTH_TOKEN : ${{ secrets.NPM_TOKEN }}
8496 run : npm publish --access public
8597
8698 winget :
8799 runs-on : windows-latest
88100 needs : goreleaser
89- if : ${{ startsWith(github.ref, 'refs/tags/v') && secrets.WINGET_CREATE_TOKEN != '' }}
101+ if : ${{ startsWith(github.ref, 'refs/tags/v') }}
90102 defaults :
91103 run :
92104 shell : pwsh
93105 working-directory : switcher/packaging/winget
94106 steps :
107+ - name : Decide winget submit
108+ id : winget_gate
109+ run : |
110+ if ([string]::IsNullOrWhiteSpace("${{ secrets.WINGET_CREATE_TOKEN }}")) {
111+ "submit=false" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
112+ } else {
113+ "submit=true" | Out-File -FilePath $env:GITHUB_OUTPUT -Encoding utf8 -Append
114+ }
115+
95116 - name : Checkout
117+ if : ${{ steps.winget_gate.outputs.submit == 'true' }}
96118 uses : actions/checkout@v4
97119
98120 - name : Install wingetcreate
121+ if : ${{ steps.winget_gate.outputs.submit == 'true' }}
99122 run : winget install --id Microsoft.WingetCreate --source winget --accept-source-agreements --accept-package-agreements
100123
101124 - name : Submit winget update PR
125+ if : ${{ steps.winget_gate.outputs.submit == 'true' }}
102126 env :
103127 WINGET_CREATE_TOKEN : ${{ secrets.WINGET_CREATE_TOKEN }}
104128 run : |
0 commit comments