v2.10.0-beta-2 (release) #29
Workflow file for this run
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: Create GitHub Release | |
| on: | |
| push: | |
| tags: | |
| - 'v*.*.*' # Tags like v1.0.0 or v1.0.0-beta or v1.0.0-beta-1 | |
| permissions: | |
| contents: "write" | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # Step 1: Checkout the repository code with submodules | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Fetches the Git history | |
| submodules: true # Clone submodules as well | |
| # Step 2: Set up environment variables | |
| - name: Set up environment variables | |
| run: | | |
| if [ -f composer.json ]; then | |
| PLUGIN_NAME=$(jq -r '.name // empty' composer.json) | |
| elif [ -f package.json ]; then | |
| PLUGIN_NAME=$(jq -r '.name // empty' package.json) | |
| else | |
| PLUGIN_NAME=$(basename "${GITHUB_REPOSITORY}") | |
| fi | |
| PLUGIN_NAME=$(basename "${PLUGIN_NAME}") | |
| VERSION=${GITHUB_REF#refs/tags/} | |
| RELEASE_VERSION="${VERSION}" | |
| RELEASE_ZIP="${PLUGIN_NAME}-${RELEASE_VERSION}.zip" | |
| echo "RELEASE_VERSION=${RELEASE_VERSION}" >> $GITHUB_ENV | |
| echo "PLUGIN_NAME=${PLUGIN_NAME}" >> $GITHUB_ENV | |
| echo "RELEASE_ZIP=${RELEASE_ZIP}" >> $GITHUB_ENV | |
| # Step 3: Get the tag message | |
| - name: Get Tag Message | |
| id: get_tag_message | |
| run: | | |
| TAG_MESSAGE=$(git tag -l "${VERSION}" --format='%(contents)') | |
| echo "RELEASE_BODY<<EOF" >> $GITHUB_ENV | |
| echo "$TAG_MESSAGE" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| # Step 4: Run setup script to create necessary files | |
| - name: Run setup script | |
| run: | | |
| chmod +x setup-git.sh | |
| ./setup-git.sh | |
| # Step 5: Generate the ZIP archive | |
| - name: Generate Release ZIP | |
| run: | | |
| PLUGIN_NAME="${PLUGIN_NAME}" | |
| # Create a temporary directory with the plugin name | |
| TMP_DIR=$(mktemp -d) | |
| # Generate exclusion arguments | |
| EXCLUDES="" | |
| [ -f .gitignore ] && EXCLUDES="$EXCLUDES --exclude-from=.gitignore" | |
| [ -f .distignore ] && EXCLUDES="$EXCLUDES --exclude-from=.distignore" | |
| # Add default exclusions | |
| EXCLUDES="$EXCLUDES --exclude=.git/" | |
| EXCLUDES="$EXCLUDES --exclude=node_modules/" | |
| EXCLUDES="$EXCLUDES --exclude=tests/" | |
| EXCLUDES="$EXCLUDES --exclude=.github/" | |
| EXCLUDES="$EXCLUDES --exclude=.env" | |
| EXCLUDES="$EXCLUDES --exclude=README.md" | |
| EXCLUDES="$EXCLUDES --exclude=${PLUGIN_NAME}/" | |
| # Copy files into the temporary directory | |
| rsync -av $EXCLUDES ./ "$TMP_DIR/${PLUGIN_NAME}" | |
| cd "$TMP_DIR" | |
| zip -r "${OLDPWD}/${RELEASE_ZIP}" "${PLUGIN_NAME}" | |
| cd "$OLDPWD" | |
| rm -rf "$TMP_DIR" | |
| # Verify that the ZIP file was created | |
| if [ ! -f "${RELEASE_ZIP}" ]; then | |
| echo "Error: The ZIP archive was not created." | |
| exit 1 | |
| fi | |
| # Step 6: Create the GitHub Release | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ env.RELEASE_VERSION }} | |
| release_name: Release ${{ env.RELEASE_VERSION }} | |
| body: ${{ env.RELEASE_BODY }} | |
| draft: false | |
| prerelease: ${{ contains(env.RELEASE_VERSION, '-beta') }} | |
| # Step 7: Attach the ZIP archive to the release | |
| - name: Upload Release Asset | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./${{ env.RELEASE_ZIP }} | |
| asset_name: ${{ env.RELEASE_ZIP }} | |
| asset_content_type: application/zip |