11name : Release Kbcli
22
33on :
4- push :
5- # release:
6- # types:
7- # - published
8-
9- # env:
10- # GH_TOKEN: ${{ github.token }}
11- # GITHUB_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
12- # TAG_NAME: ${{ github.ref_name }}
13- # GO_VERSION: "1.24"
14- # CLI_NAME: 'kbcli'
15- # JIHULAB_KBCLI_PROJECT_ID: 85948
16- # JIHULAB_ACCESS_TOKEN: ${{ secrets.GITLAB_ACCESS_TOKEN }}
17- # FURY_TOKEN: ${{ secrets.FURY_UPLOAD_TOKEN }}
18- # FURY_ACCOUNT: ${{ secrets.FURY_ACCOUNT }}
19- # GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
20- # PASSPHRASE: ${{ secrets.PASSPHRASE }}
4+ release :
5+ types :
6+ - published
7+
8+ env :
9+ GH_TOKEN : ${{ github.token }}
10+ GITHUB_TOKEN : ${{ secrets.PERSONAL_ACCESS_TOKEN }}
11+ TAG_NAME : ${{ github.ref_name }}
12+ GO_VERSION : " 1.24"
13+ CLI_NAME : ' kbcli'
14+ JIHULAB_KBCLI_PROJECT_ID : 85948
15+ JIHULAB_ACCESS_TOKEN : ${{ secrets.GITLAB_ACCESS_TOKEN }}
16+ FURY_TOKEN : ${{ secrets.FURY_UPLOAD_TOKEN }}
17+ FURY_ACCOUNT : ${{ secrets.FURY_ACCOUNT }}
18+ GPG_PRIVATE_KEY : ${{ secrets.GPG_PRIVATE_KEY }}
19+ PASSPHRASE : ${{ secrets.PASSPHRASE }}
2120
2221run-name : Release KBCLI ${{ github.ref_name }}
2322
2423jobs :
25- # create-release-jihulab:
26- # if: ${{ ! contains(github.ref_name, 'v0.5.') && ! contains(github.ref_name, 'v0.6.') && ! contains(github.ref_name, 'v0.7.') }}
27- # name: Create Release Kbcli Jihulab
28- # runs-on: ubuntu-latest
29- # steps:
30- # - uses: actions/checkout@v4
31- # - name: create gitlab release ${{ env.CLI_NAME }}
32- # run: |
33- # bash ${{ github.workspace }}/.github/utils/release_gitlab.sh \
34- # --type 1 \
35- # --project-id ${{ env.JIHULAB_KBCLI_PROJECT_ID }} \
36- # --tag-name ${{ env.TAG_NAME }} \
37- # --access-token ${{ env.JIHULAB_ACCESS_TOKEN }}
24+ create-release-jihulab :
25+ if : ${{ ! contains(github.ref_name, 'v0.5.') && ! contains(github.ref_name, 'v0.6.') && ! contains(github.ref_name, 'v0.7.') }}
26+ name : Create Release Kbcli Jihulab
27+ runs-on : ubuntu-latest
28+ steps :
29+ - uses : actions/checkout@v4
30+ - name : create gitlab release ${{ env.CLI_NAME }}
31+ run : |
32+ bash ${{ github.workspace }}/.github/utils/release_gitlab.sh \
33+ --type 1 \
34+ --project-id ${{ env.JIHULAB_KBCLI_PROJECT_ID }} \
35+ --tag-name ${{ env.TAG_NAME }} \
36+ --access-token ${{ env.JIHULAB_ACCESS_TOKEN }}
3837
3938 gorelease-assert :
40- # needs: [ create-release-jihulab ]
39+ needs : [ create-release-jihulab ]
4140 name : Upload and release kbcli
4241 runs-on : ubuntu-22.04
4342 steps :
@@ -62,127 +61,128 @@ jobs:
6261 libbtrfs-dev \
6362 libdevmapper-dev \
6463 libgpgme-dev
65- #
66- # - name: Setup Go
67- # uses: actions/setup-go@v4
68- # with:
69- # go-version: ${{ env.GO_VERSION }}
70- #
71- # - name: Import GPG key
72- # id: import_gpg
73- # uses: crazy-max/ghaction-import-gpg@v5
74- # with:
75- # gpg_private_key: ${{ env.GPG_PRIVATE_KEY }}
76- # passphrase: ${{ env.PASSPHRASE }}
77- #
78- # - uses: goreleaser/goreleaser-action@v4
79- # with:
80- # distribution: goreleaser
81- # version: latest
82- # args: release --config ${{ github.workspace }}/.goreleaser.yaml --clean
83- # env:
84- # GITHUB_TOKEN: ${{ env.GITHUB_TOKEN }}
85- # GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}
86- #
87- # - name: upload .rpm and .deb to fury.io
88- # run: |
89- # for file in $(find "${{ github.workspace }}/dist" -type f | grep -E '\.(deb|rpm)$'); do
90- # echo "Processing file: $file"
91- # curl -F package=@$file https://${{ env.FURY_TOKEN }}@push.fury.io/${{ env.FURY_ACCOUNT }}/
92- # done
93- #
94- # - name: get kbcli's release upload url
95- # run: |
96- # echo 'UPLOAD_URL='`bash ${{ github.workspace }}/.github/utils/utils.sh \
97- # --tag-name ${{ env.TAG_NAME }} \
98- # --type 3 \
99- # --github-repo "${{ github.repository }}" \
100- # --github-token ${{ env.GITHUB_TOKEN }}` >> $GITHUB_ENV
101- #
102- # - name: upload kbcli.exe to kbcli's release page for winget
103- # uses: actions/upload-release-asset@main
104- # with:
105- # upload_url: ${{ env.UPLOAD_URL }}
106- # asset_path: ${{ github.workspace }}/dist/kbcli_windows_amd64_v1/${{ env.CLI_NAME }}.exe
107- # asset_name: ${{ env.CLI_NAME }}.exe
108- # asset_content_type: application/octet-stream
109- #
110- # - name: Upload kbcli Artifact
111- # uses: actions/upload-artifact@v4
112- # with:
113- # name: ${{ env.TAG_NAME }}-kbcli
114- # path: |
115- # ./dist/*.tar.gz
116- # ./dist/*.zip
117- # if-no-files-found: error
118- # retention-days: 1
119- # overwrite: true
120- #
121- # upload-release-assert:
122- # needs: gorelease-assert
123- # runs-on: ubuntu-22.04
124- # strategy:
125- # fail-fast: false
126- # matrix:
127- # os: [linux-amd64, linux-arm64, darwin-amd64, darwin-arm64, windows-amd64, windows-arm64]
128- # steps:
129- # - uses: actions/checkout@v4
130- # - name: Download Kbcli Artifact
131- # uses: actions/download-artifact@v4
132- # with:
133- # name: ${{ env.TAG_NAME }}-kbcli
134- # path: ${{ github.workspace }}/dist
135- #
136- # - name: upload assets to gitlab
137- # run: |
138- # for file in $(find "${{ github.workspace }}/dist" -type f | grep -E '\.(gz|zip)$'); do
139- # if [[ "$file" == *"${{ matrix.os }}"* ]]; then
140- # echo "Processing file: $file"
141- # filename=$(basename "$file")
142- # bash ${{ github.workspace }}/.github/utils/release_gitlab.sh \
143- # --type 2 \
144- # --project-id ${{ env.JIHULAB_KBCLI_PROJECT_ID }} \
145- # --tag-name ${{ env.TAG_NAME }} \
146- # --asset-path $file \
147- # --asset-name $filename \
148- # --access-token ${{ env.JIHULAB_ACCESS_TOKEN }}
149- # fi
150- # done
151- #
152- # remove-artifact:
153- # needs: upload-release-assert
154- # runs-on: ubuntu-22.04
155- # steps:
156- # - name: Remove kbcli Artifact
157- # uses: geekyeggo/delete-artifact@v2
158- # continue-on-error: true
159- # with:
160- # name: ${{ env.TAG_NAME }}-kbcli
161- #
162- # release-message:
163- # runs-on: ubuntu-latest
164- # needs: [ upload-release-assert ]
165- # outputs:
166- # content-result: ${{ steps.release_message.outputs.content_result }}
167- # release-version: ${{ steps.release_message.outputs.release_version }}
168- # if: ${{ always() && ! contains(github.ref_name, 'v0.5.') && ! contains(github.ref_name, 'v0.6.') && ! contains(github.ref_name, 'v0.7.') }}
169- # steps:
170- # - name: release message
171- # id: release_message
172- # run: |
173- # CONTENT="error"
174- # if [[ "${{ needs.upload-release-assert.result }}" == "success" ]]; then
175- # CONTENT="success"
176- # fi
177- # echo 'content_result='${CONTENT} >> $GITHUB_OUTPUT
178- # echo 'release_version='${{ env.TAG_NAME }} >> $GITHUB_OUTPUT
179- #
180- # send-message:
181- # needs: [ release-message ]
182- # if: ${{ always() && ! contains(github.ref_name, 'v0.5.') && ! contains(github.ref_name, 'v0.6.') && ! contains(github.ref_name, 'v0.7.') }}
183- # uses: apecloud/apecloud-cd/.github/workflows/feishui-message.yml@v0.1.42
184- # with:
185- # TYPE: "2"
186- # CONTENT: "release kbcli ${{ needs.release-message.outputs.release-version }} ${{ needs.release-message.outputs.content-result }}"
187- # APECD_REF: "v0.1.42"
188- # secrets: inherit
64+
65+ - name : Setup Go
66+ uses : actions/setup-go@v4
67+ with :
68+ go-version : ${{ env.GO_VERSION }}
69+
70+ - name : Import GPG key
71+ id : import_gpg
72+ uses : crazy-max/ghaction-import-gpg@v5
73+ with :
74+ gpg_private_key : ${{ env.GPG_PRIVATE_KEY }}
75+ passphrase : ${{ env.PASSPHRASE }}
76+
77+ - uses : goreleaser/goreleaser-action@v4
78+ with :
79+ distribution : goreleaser
80+ version : latest
81+ args : release --config ${{ github.workspace }}/.goreleaser.yaml --clean
82+ env :
83+ GITHUB_TOKEN : ${{ env.GITHUB_TOKEN }}
84+ GPG_FINGERPRINT : ${{ steps.import_gpg.outputs.fingerprint }}
85+
86+ - name : upload .rpm and .deb to fury.io
87+ run : |
88+ df -h
89+ for file in $(find "${{ github.workspace }}/dist" -type f | grep -E '\.(deb|rpm)$'); do
90+ echo "Processing file: $file"
91+ curl -F package=@$file https://${{ env.FURY_TOKEN }}@push.fury.io/${{ env.FURY_ACCOUNT }}/
92+ done
93+
94+ - name : get kbcli's release upload url
95+ run : |
96+ echo 'UPLOAD_URL='`bash ${{ github.workspace }}/.github/utils/utils.sh \
97+ --tag-name ${{ env.TAG_NAME }} \
98+ --type 3 \
99+ --github-repo "${{ github.repository }}" \
100+ --github-token ${{ env.GITHUB_TOKEN }}` >> $GITHUB_ENV
101+
102+ - name : upload kbcli.exe to kbcli's release page for winget
103+ uses : actions/upload-release-asset@main
104+ with :
105+ upload_url : ${{ env.UPLOAD_URL }}
106+ asset_path : ${{ github.workspace }}/dist/kbcli_windows_amd64_v1/${{ env.CLI_NAME }}.exe
107+ asset_name : ${{ env.CLI_NAME }}.exe
108+ asset_content_type : application/octet-stream
109+
110+ - name : Upload kbcli Artifact
111+ uses : actions/upload-artifact@v4
112+ with :
113+ name : ${{ env.TAG_NAME }}-kbcli
114+ path : |
115+ ./dist/*.tar.gz
116+ ./dist/*.zip
117+ if-no-files-found : error
118+ retention-days : 1
119+ overwrite : true
120+
121+ upload-release-assert :
122+ needs : gorelease-assert
123+ runs-on : ubuntu-22.04
124+ strategy :
125+ fail-fast : false
126+ matrix :
127+ os : [linux-amd64, linux-arm64, darwin-amd64, darwin-arm64, windows-amd64, windows-arm64]
128+ steps :
129+ - uses : actions/checkout@v4
130+ - name : Download Kbcli Artifact
131+ uses : actions/download-artifact@v4
132+ with :
133+ name : ${{ env.TAG_NAME }}-kbcli
134+ path : ${{ github.workspace }}/dist
135+
136+ - name : upload assets to gitlab
137+ run : |
138+ for file in $(find "${{ github.workspace }}/dist" -type f | grep -E '\.(gz|zip)$'); do
139+ if [[ "$file" == *"${{ matrix.os }}"* ]]; then
140+ echo "Processing file: $file"
141+ filename=$(basename "$file")
142+ bash ${{ github.workspace }}/.github/utils/release_gitlab.sh \
143+ --type 2 \
144+ --project-id ${{ env.JIHULAB_KBCLI_PROJECT_ID }} \
145+ --tag-name ${{ env.TAG_NAME }} \
146+ --asset-path $file \
147+ --asset-name $filename \
148+ --access-token ${{ env.JIHULAB_ACCESS_TOKEN }}
149+ fi
150+ done
151+
152+ remove-artifact :
153+ needs : upload-release-assert
154+ runs-on : ubuntu-22.04
155+ steps :
156+ - name : Remove kbcli Artifact
157+ uses : geekyeggo/delete-artifact@v2
158+ continue-on-error : true
159+ with :
160+ name : ${{ env.TAG_NAME }}-kbcli
161+
162+ release-message :
163+ runs-on : ubuntu-latest
164+ needs : [ upload-release-assert ]
165+ outputs :
166+ content-result : ${{ steps.release_message.outputs.content_result }}
167+ release-version : ${{ steps.release_message.outputs.release_version }}
168+ if : ${{ always() && ! contains(github.ref_name, 'v0.5.') && ! contains(github.ref_name, 'v0.6.') && ! contains(github.ref_name, 'v0.7.') }}
169+ steps :
170+ - name : release message
171+ id : release_message
172+ run : |
173+ CONTENT="error"
174+ if [[ "${{ needs.upload-release-assert.result }}" == "success" ]]; then
175+ CONTENT="success"
176+ fi
177+ echo 'content_result='${CONTENT} >> $GITHUB_OUTPUT
178+ echo 'release_version='${{ env.TAG_NAME }} >> $GITHUB_OUTPUT
179+
180+ send-message :
181+ needs : [ release-message ]
182+ if : ${{ always() && ! contains(github.ref_name, 'v0.5.') && ! contains(github.ref_name, 'v0.6.') && ! contains(github.ref_name, 'v0.7.') }}
183+ uses : apecloud/apecloud-cd/.github/workflows/feishui-message.yml@v0.1.42
184+ with :
185+ TYPE : " 2"
186+ CONTENT : " release kbcli ${{ needs.release-message.outputs.release-version }} ${{ needs.release-message.outputs.content-result }}"
187+ APECD_REF : " v0.1.42"
188+ secrets : inherit
0 commit comments