1
- name : goreleaser
1
+ name : Release
2
2
3
3
on :
4
4
push :
5
5
tags :
6
- - " *"
7
-
8
- permissions :
9
- contents : write
6
+ - " v*.*.*"
7
+ workflow_dispatch :
10
8
11
9
jobs :
12
10
goreleaser :
13
11
runs-on : ubuntu-latest
14
12
steps :
15
- -
16
- name : Checkout
13
+ - name : Checkout
17
14
uses : actions/checkout@v2
18
15
with :
19
16
fetch-depth : 0
20
- -
21
- name : Fetch all tags
17
+
18
+ - name : Fetch all tags
22
19
run : git fetch --force --tags
23
- -
24
- name : Set up Go
20
+
21
+ - name : Set up Go
25
22
uses : actions/setup-go@v2
26
23
with :
27
24
go-version : 1.18
28
- -
29
- name : Run GoReleaser
25
+
26
+ - name : Run GoReleaser
30
27
uses : goreleaser/goreleaser-action@v2
31
28
with :
32
29
distribution : goreleaser
33
- version : ${{ env.GITHUB_REF_NAME }}
34
- args : release --rm-dist
30
+ version : latest
31
+ args : release --clean
35
32
env :
36
33
GITHUB_TOKEN : ${{ secrets.PUBLISHER_TOKEN }}
34
+
35
+ - name : Upload binaries
36
+ uses : actions/upload-artifact
37
+ with :
38
+ path : |
39
+ dist
40
+ !homebrew
41
+ !dist/**/*.tar.gz
42
+ !dist/**/*.zip
43
+ !dist/**/*.json
44
+ !dist/**/*.yaml
45
+ !dist/**/*.txt
46
+
47
+ publish-binaries :
48
+ needs : goreleaser
49
+ strategy :
50
+ matrix :
51
+ os : ["forky_darwin_amd64_v1","forky_darwin_arm64","forky_linux_amd64_v1","forky_linux_arm64","forky_windows_amd64_v1", "forky_windows_arm64"]
52
+ runs-on : ubuntu-latest
53
+ name : Publish binaries for different architectures and platforms to NPM
54
+ steps :
55
+ - name : Checkout
56
+ uses : actions/checkout@v4
57
+ with :
58
+ fetch-depth : 0
59
+
60
+ - name : Install Node
61
+ uses : actions/setup-node@v4
62
+ with :
63
+ node-version : " 16"
64
+ registry-url : " https://registry.npmjs.org"
65
+
66
+ - name : Download uploaded binaries
67
+ uses : actions/download-artifact@v4
68
+ with :
69
+ name : binaries
70
+
71
+ - name : Set the release version
72
+ shell : bash
73
+ run : echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
74
+
75
+ - name : Publish to NPM
76
+ shell : bash
77
+ run : |
78
+ cd npm
79
+ bin="forky"
80
+ version="${{ env.RELEASE_VERSION }}"
81
+ export version
82
+ node_os=$(echo "${{ matrix.os }}" | cut -d "_" -f2)
83
+ export node_os
84
+ node_arch=$(echo "${{ matrix.os }}" | cut -d "_" -f3)
85
+ export node_arch
86
+ if [ "${node_os}" = "windows" ]; then
87
+ export node_pkg="${bin}-windows-${node_arch}"
88
+ else
89
+ export node_pkg="${bin}-${node_os}-${node_arch}"
90
+ fi
91
+ mkdir -p "${node_pkg}/bin"
92
+ envsubst < package.json.tmpl > "${node_pkg}/package.json"
93
+ if [ "${node_os}" = "windows" ]; then
94
+ bin="${bin}.exe"
95
+ fi
96
+ pwd
97
+ install -D ../${{ matrix.os }}/${bin} ${node_pkg}/bin/${bin}
98
+ cd "${node_pkg}"
99
+ npm publish --access public
100
+ env :
101
+ NODE_AUTH_TOKEN : ${{secrets.NPM_API_KEY}}
102
+
103
+ publish-npm :
104
+ needs : publish-binaries
105
+ name : Publish base package to NPM
106
+ runs-on : ubuntu-latest
107
+ permissions :
108
+ contents : write
109
+ steps :
110
+ - name : Checkout
111
+ uses : actions/checkout@v4
112
+
113
+ - name : Set the release version
114
+ shell : bash
115
+ run : echo "RELEASE_VERSION=${GITHUB_REF:11}" >> $GITHUB_ENV
116
+
117
+ - name : Install Node
118
+ uses : actions/setup-node@v4
119
+ with :
120
+ node-version : " 16"
121
+ registry-url : " https://registry.npmjs.org"
122
+ - name : Publish to NPM
123
+ shell : bash
124
+ run : |
125
+ cd npm/forky
126
+ yarn install
127
+ yarn build
128
+ npm publish --access public
129
+ env :
130
+ NODE_AUTH_TOKEN : ${{secrets.NPM_API_KEY}}
0 commit comments