1313 build :
1414 name : Build
1515 runs-on : ubuntu-24.04
16+ permissions :
17+ contents : write
1618 steps :
1719 - name : Check out code into the Go module directory
18- uses : actions/checkout@v1
20+ uses : actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
21+ with :
22+ fetch-depth : 1
23+ fetch-tags : true
1924
2025 - name : Print version info
2126 id : semver
@@ -24,12 +29,12 @@ jobs:
2429
2530 - name : Set up QEMU
2631 id : qemu
27- uses : docker/setup-qemu-action@v3
32+ uses : docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
2833 with :
2934 cache-image : false
3035
3136 - name : Set up Docker Buildx
32- uses : docker/setup-buildx-action@v3
37+ uses : docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
3338
3439 - name : Build
3540 env :
3843 make release COMPRESS=yes
3944
4045 - name : Release
41- uses : softprops/action-gh-release@v1
46+ uses : softprops/action-gh-release@26994186c0ac3ef5cae75ac16aa32e8153525f77 # v1
4247 if : startsWith(github.ref, 'refs/tags/')
4348 with :
4449 files : |
@@ -52,18 +57,39 @@ jobs:
5257 env :
5358 GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
5459
55- - name : Install GitHub CLI
60+ - name : Classify release
61+ id : release-type
5662 run : |
57- curl -fsSL https://github.com/github/hub/raw/master/script/get | bash -s 2.14.1
58- sudo mv bin/hub /usr/local/bin
63+ ref="${GITHUB_REF}"
64+ if [[ "$ref" == refs/tags/* ]] \
65+ && [[ "$ref" != *-alpha.* ]] \
66+ && [[ "$ref" != *-beta.* ]] \
67+ && [[ "$ref" != *-rc.* ]]; then
68+ echo "is_release=true" >> "$GITHUB_OUTPUT"
69+ else
70+ echo "is_release=false" >> "$GITHUB_OUTPUT"
71+ fi
72+
73+ - name : Generate LGTM App token
74+ id : lgtm-app-token
75+ if : steps.release-type.outputs.is_release == 'true'
76+ uses : actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3.2.0
77+ with :
78+ client-id : ${{ secrets.LGTM_APP_CLIENT_ID }}
79+ private-key : ${{ secrets.LGTM_APP_PRIVATE_KEY }}
80+ owner : appscode
81+ repositories : krew-index
82+ permission-contents : write
83+ permission-pull-requests : write
5984
6085 - name : Clone krew-index repository
86+ if : steps.release-type.outputs.is_release == 'true'
6187 env :
62- GITHUB_USER : 1gtm
63- GITHUB_TOKEN : ${{ secrets.LGTM_GITHUB_TOKEN }}
88+ GITHUB_USER : ${{ github.actor }}
89+ GITHUB_TOKEN : ${{ steps.lgtm-app-token.outputs.token }}
6490 run : |
6591 KREW_INDEX_REPOSITORY=github.com/appscode/krew-index
66- url="https://${GITHUB_USER} :${GITHUB_TOKEN}@${KREW_INDEX_REPOSITORY}.git"
92+ url="https://x-access-token :${GITHUB_TOKEN}@${KREW_INDEX_REPOSITORY}.git"
6793 cd $RUNNER_WORKSPACE
6894 git clone $url
6995 cd $(basename $KREW_INDEX_REPOSITORY)
7298
7399 - name : Publish krew manifest
74100 env :
75- GITHUB_USER : 1gtm
76- GITHUB_TOKEN : ${{ secrets.LGTM_GITHUB_TOKEN }}
77- if : startsWith(github.event.ref, 'refs/tags/')
101+ GITHUB_USER : ${{ github.actor }}
102+ GITHUB_TOKEN : ${{ steps.lgtm-app-token.outputs.token }}
103+ if : steps.release-type.outputs.is_release == 'true'
78104 # if: startsWith(github.event.ref, 'refs/tags/') && (contains(github.ref, '-alpha.') || contains(github.ref, '-beta.') || contains(github.ref, '-rc.')) == false
79105 run : |
80106 cd $RUNNER_WORKSPACE/krew-index
0 commit comments