Skip to content

Release Kbcli

Release Kbcli #122

Workflow file for this run

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:
if: ${{ ! contains(github.ref_name, 'v0.5.') && ! contains(github.ref_name, 'v0.6.') && ! contains(github.ref_name, 'v0.7.') }}
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() && ! contains(github.ref_name, 'v0.5.') && ! contains(github.ref_name, 'v0.6.') && ! contains(github.ref_name, 'v0.7.') }}
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() && ! contains(github.ref_name, 'v0.5.') && ! contains(github.ref_name, 'v0.6.') && ! contains(github.ref_name, 'v0.7.') }}
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