Release 1.4.2 #43
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 Release | |
| on: | |
| pull_request: | |
| branches: | |
| - main | |
| - pre-release | |
| types: | |
| - closed | |
| workflow_dispatch: | |
| jobs: | |
| prepare: | |
| if: ${{ github.event_name == 'pull_request' && (github.event.pull_request.merged == true) && (contains(github.event.pull_request.labels.*.name, 'release') || contains(github.event.pull_request.labels.*.name, 'prerelease')) || github.event_name == 'workflow_dispatch' }} | |
| runs-on: ubuntu-latest | |
| outputs: | |
| version: ${{ steps.version.outputs.VERSION }} | |
| pr_body: ${{ steps.pr_body.outputs.PR_BODY }} | |
| pr_number: ${{ steps.pr_body.outputs.PR_NUMBER }} | |
| changelog: ${{ steps.pr_body.outputs.CHANGELOG }} | |
| steps: | |
| - name: 'Checkout' | |
| uses: actions/checkout@main | |
| - name: 'Setup Flutter' | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: 'stable' | |
| cache: true | |
| cache-key: "flutter-:os:-:channel:-:version:-:arch:" | |
| pub-cache-key: "flutter-pub-:os:-:channel:-:version:-:arch:" | |
| - name: 'Update version.json' | |
| run: dart run ./tool/update_version.dart | |
| - name: 'Update README images for current branch' | |
| run: dart run ./tool/update_readme_images.dart | |
| - name: 'Commit and push changes' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add . | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "chore: update version.json and README images for release" | |
| git push origin HEAD:${{ github.ref_name }} | |
| fi | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| - name: 'Get version from pubspec.yaml' | |
| id: version | |
| run: | | |
| VERSION=$(grep "^version:" pubspec.yaml | sed 's/version: //') | |
| echo "VERSION=$VERSION" >> $GITHUB_OUTPUT | |
| - name: 'Check Package Version' | |
| run: | | |
| LOCAL_VERSION=$(grep "^version:" pubspec.yaml | sed 's/version: //' | tr -d ' ') | |
| echo "Local version: $LOCAL_VERSION" | |
| # Check if version already exists on pub.dev | |
| HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" "https://pub.dev/api/packages/flutter_naver_map/versions/$LOCAL_VERSION") | |
| if [ "$HTTP_STATUS" = "200" ]; then | |
| echo "::error title=Duplicate Version Detected::Version $LOCAL_VERSION already exists on pub.dev" | |
| echo "## ⚠️ Version Check Failed" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "**Version $LOCAL_VERSION already exists on pub.dev**" >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "Please update the version in \`pubspec.yaml\` before publishing." >> $GITHUB_STEP_SUMMARY | |
| echo "" >> $GITHUB_STEP_SUMMARY | |
| echo "### Next Steps:" >> $GITHUB_STEP_SUMMARY | |
| echo "1. Update the version number in \`pubspec.yaml\`" >> $GITHUB_STEP_SUMMARY | |
| echo "2. Follow semantic versioning (patch/minor/major)" >> $GITHUB_STEP_SUMMARY | |
| echo "3. Re-run the workflow" >> $GITHUB_STEP_SUMMARY | |
| exit 1 | |
| elif [ "$HTTP_STATUS" = "404" ]; then | |
| echo "Version $LOCAL_VERSION is new, proceeding with publish" | |
| else | |
| echo "::warning title=Version Check Warning::Unexpected HTTP status $HTTP_STATUS, proceeding with caution" | |
| fi | |
| - name: 'Extract PR body and changelog for release notes' | |
| id: pr_body | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request" ]; then | |
| # Use current PR body | |
| PR_BODY="${{ github.event.pull_request.body }}" | |
| PR_NUMBER="${{ github.event.pull_request.number }}" | |
| else | |
| # Fallback: find last merged PR with release/prerelease label | |
| echo "Finding last merged PR with release/prerelease label..." | |
| # Get current branch | |
| CURRENT_BRANCH="${{ github.ref_name }}" | |
| if [ -z "$CURRENT_BRANCH" ]; then | |
| CURRENT_BRANCH="main" | |
| fi | |
| # Search for last merged PR with release or prerelease label | |
| PR_DATA=$(gh pr list \ | |
| --base "$CURRENT_BRANCH" \ | |
| --state merged \ | |
| --label "release,prerelease" \ | |
| --limit 10 \ | |
| --json number,title,body,labels \ | |
| | jq -r '.[0] // empty') | |
| if [ -n "$PR_DATA" ]; then | |
| PR_BODY=$(echo "$PR_DATA" | jq -r '.body // "No description provided"') | |
| PR_NUMBER=$(echo "$PR_DATA" | jq -r '.number') | |
| echo "Found PR #$PR_NUMBER for release notes" | |
| else | |
| PR_BODY="Manual release via workflow_dispatch" | |
| PR_NUMBER="N/A" | |
| echo "No recent release PR found, using default message" | |
| fi | |
| fi | |
| echo "PR_BODY<<EOF" >> $GITHUB_OUTPUT | |
| echo "$PR_BODY" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| echo "PR_NUMBER=$PR_NUMBER" >> $GITHUB_OUTPUT | |
| # Extract changelog for current version | |
| VERSION="${{ steps.version.outputs.VERSION }}" | |
| echo "Extracting changelog for version $VERSION..." | |
| # Read CHANGELOG.md and extract section for current version | |
| CHANGELOG_CONTENT="" | |
| if [ -f "CHANGELOG.md" ]; then | |
| # Extract content between current version header and next version header | |
| CHANGELOG_CONTENT=$(awk -v ver="## $VERSION" ' | |
| $0 ~ ver {found=1; next} | |
| found && /^## / {exit} | |
| found {print} | |
| ' CHANGELOG.md | sed '/^$/d') | |
| fi | |
| if [ -z "$CHANGELOG_CONTENT" ]; then | |
| CHANGELOG_CONTENT="No changelog entry found for version $VERSION" | |
| fi | |
| echo "CHANGELOG<<EOF" >> $GITHUB_OUTPUT | |
| echo "$CHANGELOG_CONTENT" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| create-tag: | |
| needs: prepare | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: 'Checkout' | |
| uses: actions/checkout@main | |
| with: | |
| ref: ${{ github.ref_name }} | |
| token: ${{ secrets.SELF_GITHUB_PAT }} | |
| - name: 'Pull latest changes' | |
| run: git pull origin ${{ github.ref_name }} | |
| - name: 'Create and push tag' | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git tag -a "v${{ needs.prepare.outputs.version }}" -m "Release v${{ needs.prepare.outputs.version }}" | |
| git push origin "v${{ needs.prepare.outputs.version }}" | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.SELF_GITHUB_PAT }} | |
| create-release: | |
| needs: [prepare, create-tag] | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: 'Create GitHub Release' | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.SELF_GITHUB_PAT }} | |
| with: | |
| tag_name: v${{ needs.prepare.outputs.version }} | |
| release_name: Release v${{ needs.prepare.outputs.version }} | |
| body: | | |
| ## 📝 PR Description | |
| ${{ needs.prepare.outputs.pr_body }} | |
| ## 📋 Changelog | |
| ${{ needs.prepare.outputs.changelog }} | |
| --- | |
| ## 📦 Installation | |
| Add this to your `pubspec.yaml`: | |
| ```yaml | |
| dependencies: | |
| flutter_naver_map: ^${{ needs.prepare.outputs.version }} | |
| ``` | |
| ## 🔗 Links | |
| - [pub.dev package](https://pub.dev/packages/flutter_naver_map/versions/${{ needs.prepare.outputs.version }}) | |
| - [API Reference](https://pub.dev/documentation/flutter_naver_map/${{ needs.prepare.outputs.version }}/) | |
| --- | |
| This release was automatically created from PR #${{ needs.prepare.outputs.pr_number }} | |
| draft: false | |
| prerelease: ${{ contains(github.event.pull_request.labels.*.name, 'prerelease') }} | |