Skip to content

Commit c976d2f

Browse files
committed
Upload files to the release after signing the binaries
1 parent 5899368 commit c976d2f

File tree

2 files changed

+33
-49
lines changed

2 files changed

+33
-49
lines changed

clients/cli/.github/workflows/release.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,31 @@ jobs:
3232
API_TOKEN_GITHUB: ${{ secrets.API_TOKEN_GITHUB }}
3333
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3434
VERSION: ${{ steps.version.outputs.VERSION }}
35+
- name: Upload built binaries
36+
uses: actions/upload-artifact@v4
37+
with:
38+
name: dist
39+
path: dist/
40+
- name: Create draft GitHub Release
41+
uses: softprops/action-gh-release@v1
42+
with:
43+
draft: true
44+
name: ${{ github.ref_name }}
45+
tag_name: ${{ github.ref_name }}
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
3549
sign_and_notarize:
3650
runs-on: macos-latest
3751
needs: release
3852
steps:
3953
- name: Checkout
4054
uses: actions/checkout@v4
55+
- name: Download built binaries
56+
uses: actions/download-artifact@v4
57+
with:
58+
name: dist
59+
path: dist
4160
- name: Sign CLI binaries
4261
run: bash ./build/sign.sh
4362
env:
@@ -46,6 +65,19 @@ jobs:
4665
SIGNING_IDENTITY: ${{ secrets.SIGNING_IDENTITY }}
4766
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
4867
DIST_DIR: "dist"
68+
- name: Upload signed binaries to Draft Release
69+
uses: softprops/action-gh-release@v1
70+
with:
71+
files: dist/*
72+
name: ${{ github.ref_name }}
73+
tag_name: ${{ github.ref_name }}
74+
draft: true
75+
env:
76+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
77+
- name: Publish GitHub Release
78+
run: gh release edit ${{ github.ref_name }} --draft=false
79+
env:
80+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
4981
brew:
5082
runs-on: ubuntu-latest
5183
needs: sign_and_notarize

clients/cli/build/release.sh

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -25,52 +25,4 @@ cp dist/phrase_linux_arm64 dist/linux/arm64
2525

2626
docker buildx build --tag "${IMAGE}" --tag ${IMAGE_LATEST} --platform linux/amd64,linux/arm64 -f ./Dockerfile --push .
2727

28-
# Create release
29-
function create_release_data()
30-
{
31-
cat <<EOF
32-
{
33-
"tag_name": "${VERSION}",
34-
"name": "${VERSION}",
35-
"draft": true,
36-
"prerelease": false,
37-
"body": "https://github.com/phrase/phrase-cli/blob/master/CHANGELOG.md"
38-
}
39-
EOF
40-
}
41-
42-
echo "Create release $VERSION"
43-
api_url="https://api.github.com/repos/phrase/phrase-cli/releases"
44-
response="$(curl -H "Authorization: token ${GITHUB_TOKEN}" --data "$(create_release_data)" ${api_url})"
45-
release_id=$(echo $response | python -c "import sys, json; print(json.load(sys.stdin).get('id', ''))")
46-
47-
if [ -z "$release_id" ]
48-
then
49-
echo "Failed to create GitHub release"
50-
echo $response
51-
exit 1
52-
else
53-
echo "New release created created with id: ${release_id}"
54-
fi
55-
56-
# Upload artifacts
57-
DIST_DIR="./dist"
58-
for file in "$DIST_DIR"/*; do
59-
if [ -f "$file" ]; then
60-
echo "Uploading ${file}"
61-
asset="https://uploads.github.com/repos/phrase/phrase-cli/releases/${release_id}/assets?name=$(basename "$file")"
62-
curl -sS --data-binary @"$file" -H "Authorization: token ${GITHUB_TOKEN}" -H "Content-Type: application/octet-stream" $asset > /dev/null
63-
echo Hash: $(sha256sum $file)
64-
fi
65-
done
66-
67-
echo "Publishing release"
68-
curl \
69-
--silent \
70-
-X PATCH \
71-
-H "Authorization: token ${GITHUB_TOKEN}" \
72-
-H "Accept: application/vnd.github.v3+json" \
73-
"https://api.github.com/repos/phrase/phrase-cli/releases/${release_id}" \
74-
-d '{"draft": false}' > /dev/null
75-
76-
echo "Release successful"
28+
echo "Artifacts built and ready in dist/ directory. GitHub Release creation handled in GitHub Actions workflow."

0 commit comments

Comments
 (0)