-
Notifications
You must be signed in to change notification settings - Fork 14
169 lines (153 loc) · 5.59 KB
/
release-kbcli.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
name: Release Kbcli
on:
release:
types:
- published
env:
GH_TOKEN: ${{ github.token }}
GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
TAG_NAME: ${{ github.ref_name }}
GO_VERSION: "1.21"
CLI_NAME: 'kbcli'
JIHULAB_KBCLI_PROJECT_ID: 85948
JIHULAB_ACCESS_TOKEN: ${{ secrets.GITLAB_ACCESS_TOKEN }}
FURY_TOKEN: ${{ secrets.FURY_UPLOAD_TOKEN }}
FURY_ACCOUNT: ${{ secrets.FURY_ACCOUNT }}
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
PASSPHRASE: ${{ secrets.PASSPHRASE }}
jobs:
create-release-jihulab:
name: Create Release Kbcli Jihulab
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: create gitlab release ${{ env.CLI_NAME }}
run: |
bash ${{ github.workspace }}/.github/utils/release_gitlab.sh \
--type 1 \
--project-id ${{ env.JIHULAB_KBCLI_PROJECT_ID }} \
--tag-name ${{ env.TAG_NAME }} \
--access-token ${{ env.JIHULAB_ACCESS_TOKEN }}
gorelease-assert:
needs: [ create-release-jihulab ]
name: Upload and release kbcli
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: install lib
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
libbtrfs-dev \
libdevmapper-dev \
libgpgme-dev
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: ${{ env.GO_VERSION }}
- name: Import GPG key
id: import_gpg
uses: crazy-max/ghaction-import-gpg@v5
with:
gpg_private_key: ${{ env.GPG_PRIVATE_KEY }}
passphrase: ${{ env.PASSPHRASE }}
- uses: goreleaser/goreleaser-action@v4
with:
distribution: goreleaser
version: latest
args: release --config ${{ github.workspace }}/.goreleaser.yaml --clean
env:
GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
- name: upload .rpm and .deb to fury.io
run: |
for file in $(find "${{ github.workspace }}/dist" -type f | grep -E '\.(deb|rpm)$'); do
echo "Processing file: $file"
curl -F package=@$file https://${{ env.FURY_TOKEN }}@push.fury.io/${{ env.FURY_ACCOUNT }}/
done
- name: get kbcli's release upload url
run: |
echo 'UPLOAD_URL='`bash ${{ github.workspace }}/.github/utils/utils.sh \
--tag-name ${{ env.TAG_NAME }} \
--type 3 \
--github-repo "${{ github.repository }}" \
--github-token ${{ env.GITHUB_TOKEN }}` >> $GITHUB_ENV
- name: upload kbcli.exe to kbcli's release page for winget
uses: actions/upload-release-asset@main
with:
upload_url: ${{ env.UPLOAD_URL }}
asset_path: ${{ github.workspace }}/dist/kbcli_windows_amd64_v1/${{ env.CLI_NAME }}.exe
asset_name: ${{ env.CLI_NAME }}.exe
asset_content_type: application/octet-stream
- name: Upload kbcli Artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.TAG_NAME }}-kbcli
path: |
./dist/*.tar.gz
./dist/*.zip
if-no-files-found: error
retention-days: 1
upload-release-assert:
needs: gorelease-assert
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
os: [linux-amd64, linux-arm64, darwin-amd64, darwin-arm64, windows-amd64, windows-arm64]
steps:
- uses: actions/checkout@v4
- name: Download Kbcli Artifact
uses: actions/[email protected]
with:
name: ${{ env.TAG_NAME }}-kbcli
path: ${{ github.workspace }}/dist
- name: upload assets to gitlab
run: |
for file in $(find "${{ github.workspace }}/dist" -type f | grep -E '\.(gz|zip)$'); do
if [[ "$file" == *"${{ matrix.os }}"* ]]; then
echo "Processing file: $file"
filename=$(basename "$file")
bash ${{ github.workspace }}/.github/utils/release_gitlab.sh \
--type 2 \
--project-id ${{ env.JIHULAB_KBCLI_PROJECT_ID }} \
--tag-name ${{ env.TAG_NAME }} \
--asset-path $file \
--asset-name $filename \
--access-token ${{ env.JIHULAB_ACCESS_TOKEN }}
fi
done
remove-artifact:
needs: upload-release-assert
runs-on: ubuntu-latest
steps:
- name: Remove kbcli Artifact
uses: geekyeggo/delete-artifact@v2
with:
name: ${{ env.TAG_NAME }}-kbcli
release-message:
runs-on: ubuntu-latest
needs: [ upload-release-assert ]
outputs:
content-result: ${{ steps.release_message.outputs.content_result }}
release-version: ${{ steps.release_message.outputs.release_version }}
if: ${{ always() }}
steps:
- name: release message
id: release_message
run: |
CONTENT="error"
if [[ "${{ needs.upload-release-assert.result }}" == "success" ]]; then
CONTENT="success"
fi
echo 'content_result='${CONTENT} >> $GITHUB_OUTPUT
echo 'release_version='${{ env.TAG_NAME }} >> $GITHUB_OUTPUT
send-message:
needs: [ release-message ]
if: ${{ always() }}
uses: apecloud/apecloud-cd/.github/workflows/[email protected]
with:
TYPE: "2"
CONTENT: "release kbcli ${{ needs.release-message.outputs.release-version }} ${{ needs.release-message.outputs.content-result }}"
APECD_REF: "v0.1.42"
secrets: inherit