|
1 | 1 | name: Version and Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - release: |
5 | | - types: [created] |
| 4 | + release: |
| 5 | + types: [created] |
6 | 6 |
|
7 | 7 | jobs: |
8 | | - version-and-release: |
9 | | - name: Update Version and Create Release Asset |
10 | | - runs-on: ubuntu-latest |
11 | | - permissions: |
12 | | - contents: write |
| 8 | + version-and-release: |
| 9 | + name: Update Version and Create Release Asset |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + contents: write |
13 | 13 |
|
14 | | - steps: |
15 | | - - name: Checkout code at tag |
16 | | - uses: actions/checkout@v4 |
17 | | - with: |
18 | | - ref: ${{ github.event.release.tag_name }} |
19 | | - fetch-depth: 0 |
| 14 | + steps: |
| 15 | + - name: Checkout code at tag |
| 16 | + uses: actions/checkout@v4 |
| 17 | + with: |
| 18 | + ref: ${{ github.event.release.tag_name }} |
| 19 | + fetch-depth: 0 |
20 | 20 |
|
21 | | - - name: Get version from tag |
22 | | - id: get_version |
23 | | - run: | |
24 | | - # Extract version from tag (remove 'v' prefix if present) |
25 | | - TAG_NAME="${{ github.event.release.tag_name }}" |
26 | | - VERSION="${TAG_NAME#v}" |
| 21 | + - name: Get version from tag |
| 22 | + id: get_version |
| 23 | + run: | |
| 24 | + # Extract version from tag (remove 'v' prefix if present) |
| 25 | + TAG_NAME="${{ github.event.release.tag_name }}" |
| 26 | + VERSION="${TAG_NAME#v}" |
27 | 27 |
|
28 | | - echo "version=$VERSION" >> $GITHUB_OUTPUT |
29 | | - echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT |
30 | | - echo "Version: $VERSION" |
31 | | - echo "Tag: $TAG_NAME" |
| 28 | + echo "version=$VERSION" >> $GITHUB_OUTPUT |
| 29 | + echo "tag=$TAG_NAME" >> $GITHUB_OUTPUT |
| 30 | + echo "Version: $VERSION" |
| 31 | + echo "Tag: $TAG_NAME" |
32 | 32 |
|
33 | | - - name: Replace __VERSION__ in plugin file |
34 | | - run: | |
35 | | - sed -i "s/__VERSION__/${{ steps.get_version.outputs.version }}/g" hm-query-loop.php |
36 | | - echo "Updated plugin header:" |
37 | | - cat hm-query-loop.php | grep "Version:" |
38 | | - echo "Updated version constant:" |
39 | | - cat hm-query-loop.php | grep "HM_QUERY_LOOP_VERSION" |
| 33 | + - name: Replace __VERSION__ in plugin file |
| 34 | + run: | |
| 35 | + sed -i "s/__VERSION__/${{ steps.get_version.outputs.version }}/g" hm-query-loop.php |
| 36 | + echo "Updated plugin header:" |
| 37 | + cat hm-query-loop.php | grep "Version:" |
| 38 | + echo "Updated version constant:" |
| 39 | + cat hm-query-loop.php | grep "HM_QUERY_LOOP_VERSION" |
40 | 40 |
|
41 | | - - name: Commit version changes to tag |
42 | | - run: | |
43 | | - git config --local user.email "github-actions[bot]@users.noreply.github.com" |
44 | | - git config --local user.name "github-actions[bot]" |
| 41 | + - name: Commit version changes to tag |
| 42 | + run: | |
| 43 | + git config --local user.email "github-actions[bot]@users.noreply.github.com" |
| 44 | + git config --local user.name "github-actions[bot]" |
45 | 45 |
|
46 | | - # Add and commit the versioned file |
47 | | - git add hm-query-loop.php |
48 | | - git commit -m "Update version to ${{ steps.get_version.outputs.version }}" |
| 46 | + # Add and commit the versioned file |
| 47 | + git add hm-query-loop.php |
| 48 | + git commit -m "Update version to ${{ steps.get_version.outputs.version }}" |
49 | 49 |
|
50 | | - # Delete the old tag and create a new one pointing to the new commit |
51 | | - git tag -d "${{ steps.get_version.outputs.tag }}" |
52 | | - git tag -a "${{ steps.get_version.outputs.tag }}" -m "Release ${{ steps.get_version.outputs.tag }}" |
| 50 | + # Delete the old tag and create a new one pointing to the new commit |
| 51 | + git tag -d "${{ steps.get_version.outputs.tag }}" |
| 52 | + git tag -a "${{ steps.get_version.outputs.tag }}" -m "Release ${{ steps.get_version.outputs.tag }}" |
53 | 53 |
|
54 | | - # Force push the updated tag |
55 | | - git push origin "${{ steps.get_version.outputs.tag }}" --force |
| 54 | + # Force push the updated tag |
| 55 | + git push origin "${{ steps.get_version.outputs.tag }}" --force |
56 | 56 |
|
57 | | - - name: Create ZIP archive |
58 | | - run: | |
59 | | - mkdir -p release |
| 57 | + - name: Create ZIP archive |
| 58 | + run: | |
| 59 | + mkdir -p release |
60 | 60 |
|
61 | | - # Create a clean copy excluding dev files |
62 | | - rsync -av --exclude='.git' \ |
63 | | - --exclude='.github' \ |
64 | | - --exclude='node_modules' \ |
65 | | - --exclude='src' \ |
66 | | - --exclude='release' \ |
67 | | - --exclude='.gitignore' \ |
68 | | - --exclude='.gitattributes' \ |
69 | | - --exclude='package.json' \ |
70 | | - --exclude='package-lock.json' \ |
71 | | - --exclude='RELEASE.md' \ |
72 | | - ./ release/hm-query-loop/ |
| 61 | + # Create a clean copy excluding dev files |
| 62 | + rsync -av --exclude='.git' \ |
| 63 | + --exclude='.github' \ |
| 64 | + --exclude='node_modules' \ |
| 65 | + --exclude='src' \ |
| 66 | + --exclude='release' \ |
| 67 | + --exclude='.gitignore' \ |
| 68 | + --exclude='.gitattributes' \ |
| 69 | + --exclude='package.json' \ |
| 70 | + --exclude='package-lock.json' \ |
| 71 | + --exclude='RELEASE.md' \ |
| 72 | + ./ release/hm-query-loop/ |
73 | 73 |
|
74 | | - # Create ZIP |
75 | | - cd release |
76 | | - zip -r "hm-query-loop-${{ steps.get_version.outputs.tag }}.zip" hm-query-loop/ |
77 | | - cd .. |
| 74 | + # Create ZIP |
| 75 | + cd release |
| 76 | + zip -r "hm-query-loop-${{ steps.get_version.outputs.tag }}.zip" hm-query-loop/ |
| 77 | + cd .. |
78 | 78 |
|
79 | | - echo "Created: release/hm-query-loop-${{ steps.get_version.outputs.tag }}.zip" |
| 79 | + echo "Created: release/hm-query-loop-${{ steps.get_version.outputs.tag }}.zip" |
80 | 80 |
|
81 | | - - name: Upload ZIP to release |
82 | | - uses: softprops/action-gh-release@v1 |
83 | | - with: |
84 | | - tag_name: ${{ github.event.release.tag_name }} |
85 | | - files: | |
86 | | - release/hm-query-loop-${{ steps.get_version.outputs.tag }}.zip |
87 | | - env: |
88 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 81 | + - name: Upload ZIP to release |
| 82 | + uses: softprops/action-gh-release@v1 |
| 83 | + with: |
| 84 | + tag_name: ${{ github.event.release.tag_name }} |
| 85 | + files: | |
| 86 | + release/hm-query-loop-${{ steps.get_version.outputs.tag }}.zip |
| 87 | + env: |
| 88 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments