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: 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 oreui-utilities.mcpack.zip . -x '.github/*' | |
# Step 3: Find the latest release and upload the zip file | |
- name: Upload to latest release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Get the latest release ID | |
latest_release=$(curl -s \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
"https://api.github.com/repos/${{ github.repository }}/releases/latest" | jq -r .id) | |
# Upload the zip file to the latest release | |
curl -s -X POST \ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Content-Type: application/zip" \ | |
--data-binary @reponame.mcpack.zip \ | |
"https://uploads.github.com/repos/${{ github.repository }}/releases/$latest_release/assets?name=reponame.mcpack.zip" |