Skip to content

Commit

Permalink
add binaries to release
Browse files Browse the repository at this point in the history
  • Loading branch information
biryukovmaxim committed Sep 13, 2024
1 parent b51a6a6 commit 4895041
Showing 1 changed file with 32 additions and 7 deletions.
39 changes: 32 additions & 7 deletions .github/workflows/anchor-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ jobs:
with:
path: ~/.cargo/bin/anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }}
key: ${{ runner.os }}-anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }}-${{ github.event.inputs.rust_version }}

- name: Build Anchor CLI
if: steps.cache-anchor-restore.outputs.cache-hit != 'true'
run: |
Expand All @@ -88,17 +89,41 @@ jobs:
path: ~/.cargo/bin/anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }}
key: ${{ runner.os }}-anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }}-${{ github.event.inputs.rust_version }}

- name: Release
- name: Check existing release
id: check_release
run: |
release_id=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/releases/tags/anchor-${{ steps.set_version.outputs.version_or_rev }}" \
| jq -r '.id')
if [ "$release_id" != "null" ]; then
echo "release_exists=true" >> $GITHUB_OUTPUT
echo "release_id=$release_id" >> $GITHUB_OUTPUT
else
echo "release_exists=false" >> $GITHUB_OUTPUT
fi
- name: Create Release
if: steps.check_release.outputs.release_exists == 'false'
id: create_release
uses: softprops/action-gh-release@v1
with:
tag_name: anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }}
name: Anchor CLI ${{ steps.set_version.outputs.version_or_rev }} for ${{ github.event.inputs.target }}
files: ~/.cargo/bin/anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }}
tag_name: anchor-${{ steps.set_version.outputs.version_or_rev }}
name: Anchor CLI ${{ steps.set_version.outputs.version_or_rev }}
body: "This release contains Anchor CLI binaries for different targets."
draft: false
prerelease: false
generate_release_notes: true

- name: Upload binary to release
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.check_release.outputs.release_exists == 'true' && format('https://uploads.github.com/repos/{0}/releases/{1}/assets{{?name,label}}', github.repository, steps.check_release.outputs.release_id) || steps.create_release.outputs.upload_url }}
asset_path: ~/.cargo/bin/anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }}
asset_name: anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }}
asset_content_type: application/octet-stream

- name: Get Release URL
run: |
echo "Release URL: ${{ steps.release.outputs.url }}"
echo "Binary name: anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }}"
echo "Release URL: https://github.com/${{ github.repository }}/releases/tag/anchor-${{ steps.set_version.outputs.version_or_rev }}"
echo "Binary name: anchor-${{ steps.set_version.outputs.version_or_rev }}-${{ github.event.inputs.target }}"

0 comments on commit 4895041

Please sign in to comment.