Skip to content

Commit 3acff7c

Browse files
Sign phar when releasing it (#465)
* adds builds steps to sign phar when releasing it * uses default GITHUB_TOKEN
1 parent 3bcc979 commit 3acff7c

File tree

1 file changed

+32
-11
lines changed

1 file changed

+32
-11
lines changed

.github/workflows/build.yml

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
php-version: ${{ matrix.php-versions }}
2626
tools: composer:v2.2
2727
env:
28-
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
28+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2929

3030
- name: Validate composer.json and composer.lock
3131
run: composer validate
@@ -71,7 +71,7 @@ jobs:
7171
php-version: 7.4
7272
tools: composer:v2.2
7373
env:
74-
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
7575

7676
- name: Install dependencies
7777
run: composer install --prefer-dist --no-dev -o
@@ -84,7 +84,7 @@ jobs:
8484

8585
- name: "Rename phar to avoid conflicts"
8686
run: mv ./phparkitect.phar phparkitect-${{ github.sha }}.phar
87-
87+
8888
- name: "Upload phar file artifact"
8989
uses: actions/upload-artifact@v4
9090
with:
@@ -104,7 +104,7 @@ jobs:
104104
with:
105105
php-version: ${{ matrix.php-versions }}
106106
env:
107-
GITHUB_TOKEN: ${{ secrets.TOKEN_GITHUB }}
107+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
108108

109109
- name: "Download phar ./phparkitect-${{ github.sha }}.phar"
110110
uses: actions/download-artifact@v4
@@ -119,20 +119,41 @@ jobs:
119119
needs: [build, smoke-test-phar]
120120
runs-on: "ubuntu-22.04"
121121
if: github.event_name == 'release'
122+
permissions:
123+
contents: write
122124
steps:
123125
- name: "Download phar ./phparkitect-${{ github.sha }}.phar"
124126
uses: actions/download-artifact@v4
125127
with:
126128
# will download phar in project root
127129
name: phar-artifact
128-
129-
- name: Upload Release Asset
130-
uses: svenstaro/upload-release-action@v2
130+
131+
- name: Import GPG key
132+
uses: crazy-max/ghaction-import-gpg@v6
133+
with:
134+
gpg_private_key: ${{ secrets.GPG_KEY_47CD54B6398FE21B3709D0A4D9C905CED1932CA2 }}
135+
passphrase: ${{ secrets.GPG_KEY_47CD54B6398FE21B3709D0A4D9C905CED1932CA2_PASSPHRASE }}
136+
137+
- name: Rename phar
138+
run: mv ./phparkitect-${{ github.sha }}.phar phparkitect.phar
139+
140+
- name: Sign the PHAR
141+
run: |
142+
gpg --local-user 47CD54B6398FE21B3709D0A4D9C905CED1932CA2 \
143+
--batch \
144+
--yes \
145+
--passphrase="${{ secrets.GPG_KEY_47CD54B6398FE21B3709D0A4D9C905CED1932CA2_PASSPHRASE }}" \
146+
--detach-sign \
147+
--output ./phparkitect.phar.asc \
148+
./phparkitect.phar
149+
150+
- name: Add phar to the release
151+
uses: softprops/action-gh-release@v2
131152
with:
132-
repo_token: ${{ secrets.GITHUB_TOKEN }}
133-
file: ./phparkitect-${{ github.sha }}.phar
134-
asset_name: phparkitect.phar
135-
tag: ${{ github.ref }}
153+
token: ${{ secrets.GITHUB_TOKEN }}
154+
files: |
155+
phparkitect.phar
156+
phparkitect.phar.asc
136157
137158
publish_docker_images:
138159
needs: [build, smoke-test-phar]

0 commit comments

Comments
 (0)