upload asset is on different url; remove removing assets #5
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish to Public Repo Release | |
on: | |
push: | |
tags: | |
- 'v*.*.*' | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout private repo | |
uses: actions/checkout@v3 | |
- name: Prepare file for release | |
run: | | |
FILE_NAME="package.readme.txt" | |
echo 'this is sample publish from private repo' > $FILE_NAME | |
mkdir -p ./packages | |
mv $FILE_NAME ./packages/ | |
echo "Preparing file for release" | |
- name: Set public repo URLs | |
run: | | |
echo "REPO_API_URL=https://api.github.com/repos/boly38/chickenbot-web" >> $GITHUB_ENV | |
echo "UPLOAD_API_URL=https://uploads.github.com/repos/boly38/chickenbot-web" >> $GITHUB_ENV | |
- name: Create Release in Public Repo | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
run: | | |
RESPONSE_FILE="release_response.json" | |
# Create the release and save the response in a file | |
curl -s -X POST \ | |
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \ | |
-H "Content-Type: application/json" \ | |
-d '{ | |
"tag_name": "'${{ github.ref_name }}'", | |
"target_commitish": "main", | |
"name": "'${{ github.ref_name }}'", | |
"body": "Release from private repo", | |
"draft": true, | |
"prerelease": false | |
}' \ | |
${{ env.REPO_API_URL }}/releases > $RESPONSE_FILE | |
# Display the API response | |
echo "Release creation response:" | |
cat $RESPONSE_FILE | |
# Extract the release ID from the response file | |
RELEASE_ID=$(jq -r '.id' $RESPONSE_FILE) | |
if [ "$RELEASE_ID" == "null" ]; then | |
echo "Failed to create release: $(cat $RESPONSE_FILE)" | |
exit 1 | |
fi | |
echo "Release created successfully! ID: $RELEASE_ID" | |
- name: Upload asset to Release | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
run: | | |
curl -L \ | |
-X POST \ | |
-H "Accept: application/vnd.github+json" \ | |
-H "Authorization: token ${{ secrets.PAT_TOKEN }}" \ | |
-H "X-GitHub-Api-Version: 2022-11-28" \ | |
-H "Content-Type: application/octet-stream" \ | |
"${{ env.UPLOAD_API_URL }}/releases/${RELEASE_ID}/assets?name=package.readme.txt" \ | |
--data-binary @./packages/package.readme.txt | |
- name: Echo release and download links | |
env: | |
GITHUB_TOKEN: ${{ secrets.PAT_TOKEN }} | |
run: | | |
RELEASE_URL="https://github.com/boly38/chickenbot-web/releases/tag/${{ github.ref_name }}" | |
DOWNLOAD_URL="https://github.com/boly38/chickenbot-web/releases/download/${{ github.ref_name }}/package.readme.txt" | |
echo "Release page: $RELEASE_URL" | |
echo "Direct download link: $DOWNLOAD_URL" |