Refactor order parsing to return raw data and enhance logging for sal… #14
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: Plugin Release | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: write | |
| jobs: | |
| release: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v2 | |
| with: | |
| fetch-depth: '0' | |
| - name: Get current version | |
| id: get_version | |
| run: | | |
| version=$(grep -oP 'Version:\s*\K[0-9.]+' lemonsqueezy-api.php) | |
| echo "Current version: $version" | |
| echo "version=$version" >> $GITHUB_ENV | |
| - name: Bump version if release | |
| if: contains(github.event.head_commit.message, 'release') | |
| run: | | |
| current_version=$(grep -oP 'Version:\s*\K[0-9.]+' lemonsqueezy-api.php) | |
| next_version=$(awk -F. '{print $1 "." ($2+1)}' <<< "$current_version") | |
| sed -i "s/Version: $current_version/Version: $next_version/" lemonsqueezy-api.php | |
| echo "new_version=$next_version" >> $GITHUB_ENV | |
| - name: Commit version bump | |
| if: contains(github.event.head_commit.message, 'release') | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add lemonsqueezy-api.php | |
| git commit -m "Bump version to ${{ env.new_version }}" | |
| git push | |
| - name: Generate changelog | |
| id: changelog | |
| run: | | |
| # Get the latest tag (previous version) | |
| latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| # Generate changelog | |
| if [ -z "$latest_tag" ]; then | |
| # If no previous tag exists, get all commits | |
| changelog=$(git log --pretty=format:"- %s (%h)" --no-merges) | |
| else | |
| # Get commits since the last tag | |
| changelog=$(git log ${latest_tag}..HEAD --pretty=format:"- %s (%h)" --no-merges) | |
| fi | |
| # Save changelog to file and environment | |
| echo "$changelog" > CHANGELOG.txt | |
| echo "CHANGELOG<<EOF" >> $GITHUB_ENV | |
| echo "$changelog" >> $GITHUB_ENV | |
| echo "EOF" >> $GITHUB_ENV | |
| echo "previous_tag=$latest_tag" >> $GITHUB_ENV | |
| - name: Create zip file | |
| run: | | |
| mkdir -p lemonsqueezy-api | |
| rsync -av --exclude='.git' --exclude='.github' --exclude='lemonsqueezy-api' ./ lemonsqueezy-api/ | |
| zip -r lemonsqueezy-api.zip lemonsqueezy-api | |
| rm -rf lemonsqueezy-api | |
| - name: Create GitHub Release | |
| if: contains(github.event.head_commit.message, 'release') | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| files: lemonsqueezy-api.zip | |
| tag_name: "v${{ env.new_version }}" | |
| name: "Release v${{ env.new_version }}" | |
| body: | | |
| ## Release v${{ env.new_version }} | |
| ### Changes in this release: | |
| ${{ env.CHANGELOG }} | |
| --- | |
| **Full Changelog**: ${{ env.previous_tag != '' && format('https://github.com/sinanisler/lemonsqueezy-api-wordpress/compare/{0}...v{1}', env.previous_tag, env.new_version) || format('https://github.com/sinanisler/lemonsqueezy-api-wordpress/commits/v{0}', env.new_version) }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Create GitHub Pre-release | |
| if: contains(github.event.head_commit.message, 'alphatag') | |
| uses: softprops/action-gh-release@v1 | |
| with: | |
| prerelease: true | |
| files: lemonsqueezy-api.zip | |
| tag_name: "pre-v${{ env.version }}" | |
| name: "Pre-release v${{ env.version }}" | |
| body: | | |
| ## Pre-release v${{ env.version }} | |
| ### Changes in this pre-release: | |
| ${{ env.CHANGELOG }} | |
| --- | |
| **Note**: This is a pre-release version for testing purposes. | |
| **Full Changelog**: ${{ env.previous_tag != '' && format('https://github.com/sinanisler/lemonsqueezy-api-wordpress/compare/{0}...pre-v{1}', env.previous_tag, env.version) || format('https://github.com/sinanisler/lemonsqueezy-api-wordpress/commits/pre-v{0}', env.version) }} | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |