Skip to content

Workflow file for this run

name: Zip and Attach to Latest Release
on:
push:
branches:
- main # Change to your default branch if needed
jobs:
build-and-release:
runs-on: ubuntu-latest
steps:
# Step 1: Check out the current repository code
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Create a ZIP file excluding the .github folder
- name: Create ZIP file
run: |
zip -r reponame.mcpack.zip . -x '.github/*'
# Step 3: Get the latest release ID
- name: Get Latest Release
id: latest_release
run: |
release_data=$(curl -s \
-H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/releases/latest")
echo "release_data=$release_data" >> $GITHUB_ENV
echo "::set-output name=release_id::$(echo $release_data | jq -r .id)"
# Step 4: Upload the ZIP to the latest release
- name: Upload to latest release
run: |
upload_url=$(echo $release_data | jq -r .upload_url | sed -e "s/{?name,label}//")
echo "Uploading to release $upload_url"
curl -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/zip" \
--data-binary @reponame.mcpack.zip \
"$upload_url?name=reponame.mcpack.zip"