- Notifications
You must be signed in to change notification settings - Fork13
Merge pull request #78 from Sonoran-Software/3.2.15-hf#220
This file contains hidden or 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:Sonoran CAD Framework Resource Build | |
| on: | |
| push: | |
| branches: | |
| -master | |
| -'**'# This will trigger on all branches | |
| jobs: | |
| release: | |
| if:github.ref == 'refs/heads/master'# Run only on master branch | |
| runs-on:ubuntu-latest | |
| steps: | |
| -name:Checkout Code | |
| uses:actions/checkout@v2 | |
| -name:Extract Version | |
| id:extract-version | |
| run:| | |
| VERSION=$(grep -oP "version '\K\d+\.\d+\.\d+" sonorancad/fxmanifest.lua) | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Grabbed version number of $VERSION, will be used for this release..." | |
| shell:bash | |
| -name:Clone included submodules | |
| id:clone-submodules | |
| run:| | |
| git submodule deinit -f --all | |
| git submodule sync | |
| git submodule update --init --recursive | |
| git submodule update --remote --merge | |
| shell:bash | |
| -name:Move external submodule config.dist.lua files | |
| run:| | |
| find sonorancad/submodules/ -type f -name '*_config.dist.lua' -exec mv -f {} sonorancad/configuration/ \; | |
| shell:bash | |
| -name:Cleanup & Zip Directories | |
| id:zip-dirs | |
| run:| | |
| VERSION=${{ steps.extract-version.outputs.version }} | |
| find sonorancad/plugins -mindepth 1 -type d -exec sh -c 'case "$0" in */readme.md|*/template) ;; *) rm -r "$0" ;; esac' {} \; & wait | |
| rsync -a --exclude="[sonorancad]" --exclude=".git" --exclude=".vscode" --exclude=".github" ./ ./[sonorancad] | |
| zip -r "sonorancad-$VERSION.zip" [sonorancad]/ | |
| echo "Zipped sonorancad/ and sonorancad_updatehelper/ directories" | |
| shell:bash | |
| -name:Create or Recreate Release | |
| id:create-update-release | |
| env: | |
| GITHUB_TOKEN:${{ secrets.GITHUB_TOKEN }} | |
| run:| | |
| VERSION=${{ steps.extract-version.outputs.version }} | |
| RELEASE_NAME="Release $VERSION" | |
| RELEASE_TAG="v$VERSION" | |
| # Check if the release already exists | |
| if curl --fail -sSL "https://api.github.com/repos/${{ github.repository }}/releases/tags/$RELEASE_TAG"; then | |
| echo "Deleting existing release $RELEASE_NAME" | |
| RELEASE_ID=$(curl -X GET "https://api.github.com/repos/${{ github.repository }}/releases/tags/$RELEASE_TAG" \ | |
| -H "Authorization: token $GITHUB_TOKEN" | jq -r '.id') | |
| curl -X DELETE "https://api.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID" \ | |
| -H "Authorization: token $GITHUB_TOKEN" | |
| else | |
| echo "Release $RELEASE_NAME does not exist" | |
| fi | |
| # Check if the tag exists, and if it does, delete it | |
| if curl --fail -sSL "https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$RELEASE_TAG"; then | |
| echo "Deleting existing tag $RELEASE_TAG" | |
| REF_SHA=$(curl -sSL "https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$RELEASE_TAG" | jq -r '.object.sha') | |
| curl -X DELETE "https://api.github.com/repos/${{ github.repository }}/git/refs/tags/$RELEASE_TAG" \ | |
| -H "Authorization: token $GITHUB_TOKEN" | |
| else | |
| echo "Tag $RELEASE_TAG does not exist" | |
| fi | |
| echo "Creating a new release $RELEASE_NAME" | |
| RESPONSE=$(curl -X POST "https://api.github.com/repos/${{ github.repository }}/releases" \ | |
| -H "Authorization: token $GITHUB_TOKEN" \ | |
| -d "{\"tag_name\":\"$RELEASE_TAG\",\"name\":\"$RELEASE_NAME\",\"target_commitish\":\"master\",\"draft\":false,\"prerelease\":false,\"generate_release_notes\":true,\"make_latest\":\"true\"}") | |
| echo $RESPONSE | |
| RELEASE_ID=$(echo $RESPONSE | jq -r '.id') | |
| # Upload the zip file as a release asset | |
| echo "Uploading zip to release $RELEASE_NAME" | |
| UPLOAD_URL="https://uploads.github.com/repos/${{ github.repository }}/releases/$RELEASE_ID/assets?name=sonorancad-$VERSION.zip" | |
| curl -H "Authorization: token $GITHUB_TOKEN" \ | |
| -H "Content-Type: application/zip" \ | |
| --data-binary "@sonorancad-$VERSION.zip" \ | |
| "$UPLOAD_URL" | |
| shell:bash | |
| upload-artifact: | |
| if:github.ref != 'refs/heads/master'# Run only on non-master branches | |
| runs-on:ubuntu-latest | |
| steps: | |
| -name:Checkout Code | |
| uses:actions/checkout@v2 | |
| -name:Extract Version | |
| id:extract-version | |
| run:| | |
| VERSION=$(grep -oP "version '\K\d+\.\d+\.\d+" sonorancad/fxmanifest.lua) | |
| echo "version=$VERSION" >> "$GITHUB_OUTPUT" | |
| echo "Grabbed version number of $VERSION, will be used for this artifact..." | |
| shell:bash | |
| -name:Clone included submodules | |
| id:clone-submodules | |
| run:| | |
| git submodule deinit -f --all | |
| git submodule sync | |
| git submodule update --init --recursive | |
| git submodule update --remote --merge | |
| shell:bash | |
| -name:Move external submodule config.dist.lua files | |
| run:| | |
| find sonorancad/submodules/ -type f -name '*_config.dist.lua' -exec mv -f {} sonorancad/configuration/ \; | |
| shell:bash | |
| -name:Cleanup & Zip Directories | |
| id:zip-dirs | |
| run:| | |
| VERSION=${{ steps.extract-version.outputs.version }} | |
| find sonorancad/plugins -mindepth 1 -type d -exec sh -c 'case "$0" in */readme.md|*/template) ;; *) rm -r "$0" ;; esac' {} \; & wait | |
| rsync -a --exclude="[sonorancad]" --exclude=".git" --exclude=".vscode" --exclude=".github" ./ ./[sonorancad] | |
| zip -r "sonorancad-$VERSION.zip" [sonorancad]/ | |
| echo "Zipped sonorancad/ and sonorancad_updatehelper/ directories" | |
| shell:bash | |
| -name:Upload ZIP as Artifact | |
| uses:actions/upload-artifact@v4 | |
| with: | |
| name:sonorancad-artifact | |
| path:sonorancad-*.zip |