t3 #36
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: Release | |
| on: | |
| push: | |
| branches: | |
| - '**' | |
| tags: | |
| - '*.*.*' | |
| pull_request: | |
| branches: | |
| - main | |
| env: | |
| ADDON_NAME: 'MemoryGarbageCollector' | |
| jobs: | |
| prepare-release: | |
| name: "Prepare release" | |
| runs-on: ubuntu-latest | |
| outputs: | |
| zip_name: ${{ env.ADDON_ZIP_NAME }} | |
| version: ${{ env.ADDON_VERSION }} | |
| steps: | |
| - name: Check out repository | |
| uses: actions/checkout@v4 | |
| - name: Set version variables | |
| run: | | |
| version=$(echo "${{ github.ref_name }}" | sed -e 's/[^[:alnum:]._-]/-/g') | |
| echo "ADDON_VERSION=$version" >> $GITHUB_ENV | |
| echo "ADDON_ZIP_NAME=${{ env.ADDON_NAME }}-$version.zip" >> $GITHUB_ENV | |
| - name: Update version in files | |
| run: | | |
| cd ${{ env.ADDON_NAME }} | |
| echo "Version: ${{ env.ADDON_VERSION }}" | |
| # Replace text version | |
| sed -i "s/version = \"dev\"/version = \"${{ env.ADDON_VERSION }}\"/g" ${{ env.ADDON_NAME }}.lua | |
| sed -i "s/## Version: dev/## Version: ${{ env.ADDON_VERSION }}/g" ${{ env.ADDON_NAME }}.addon | |
| # Replace numeric version only for tag build | |
| if [ "${{ github.ref_type }}" == "tag" ]; then | |
| # Split major.minor.patch | |
| IFS='.' read -r MAJOR MINOR PATCH <<< "${{ github.ref_name }}" | |
| # Pad every part to 3 digit | |
| MAJOR_PAD=$(printf "%03d" "$MAJOR") | |
| MINOR_PAD=$(printf "%03d" "$MINOR") | |
| PATCH_PAD=$(printf "%03d" "$PATCH") | |
| VERSION_INT=$((10#$MAJOR_PAD$MINOR_PAD$PATCH_PAD)) | |
| echo "AddOnVersion: $VERSION_INT" | |
| sed -i "s/## AddOnVersion: 99999999/## AddOnVersion: $VERSION_INT/g" ${{ env.ADDON_NAME }}.addon | |
| fi | |
| - name: Create ZIP archive | |
| run: | | |
| zip -r --quiet "$(pwd)/${{ env.ADDON_ZIP_NAME }}" "${{ env.ADDON_NAME }}" | |
| - name: Upload build artifacts | |
| if: ${{ github.ref_type != 'tag' }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| path: ${{ env.ADDON_ZIP_NAME }} | |
| retention-days: 3 | |
| - name: Extract latest changes for GitHub | |
| #if: ${{ github.ref_type == 'tag' }} | |
| run: | | |
| mv artifacts/CHANGELOG.md . | |
| awk '/^## / { if (!found) { found=1; print; next } else { exit } } found' CHANGELOG.md > latest_changes.md | |
| cat latest_changes.md | |
| - name: Create GitHub Release | |
| #if: ${{ github.ref_type == 'tag' }} | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| name: "${{ env.ADDON_VERSION }}" | |
| artifacts: "${{ env.ADDON_ZIP_NAME }}" | |
| artifactContentType: application/zip | |
| bodyFile: latest_changes.md | |
| prerelease: true | |
| makeLatest: true | |
| - name: Upload to ESOUI | |
| if: ${{ github.ref_type == 'tag' }} | |
| env: | |
| addon_id: ${{ vars.ESOUI_ADDON_ID }} | |
| api_key: ${{ secrets.ESOUI_API_KEY }} | |
| addon_version: ${{ env.ADDON_VERSION }} | |
| addon_zip: ${{ env.ADDON_ZIP_NAME }} | |
| run: | | |
| curl --fail -X POST \ | |
| -H "x-api-token: $api_key" \ | |
| -F "id=$addon_id" \ | |
| -F "version=$addon_version" \ | |
| -F "updatefile=@$addon_zip" \ | |
| -F "changelog=$(cat CHANGELOG.md)" \ | |
| https://api.esoui.com/addons/updatetest |