|
1 | 1 | name: Release |
2 | 2 |
|
3 | 3 | on: |
4 | | - schedule: |
5 | | - - cron: "0 8 * * 1" # At 08:00 on Monday. |
6 | | - workflow_dispatch: # Allows manual triggering |
| 4 | + schedule: |
| 5 | + - cron: "0 8 * * 1" # At 08:00 on Monday. |
| 6 | + workflow_dispatch: # Allows manual triggering |
7 | 7 |
|
8 | 8 | jobs: |
9 | | - update: |
10 | | - name: Update version |
11 | | - runs-on: ubuntu-latest |
12 | | - timeout-minutes: 10 |
13 | | - |
14 | | - steps: |
15 | | - - name: Check out repository |
16 | | - uses: actions/checkout@v3 |
17 | | - with: |
18 | | - fetch-depth: 0 # Fetch all history so we can access tags and commits |
19 | | - fetch-tags: true # Ensure tags are fetched |
20 | | - |
21 | | - - name: Install pnpm |
22 | | - uses: pnpm/action-setup@v4 |
23 | | - with: |
24 | | - version: 9 |
25 | | - |
26 | | - - name: Install Node.js LTS |
27 | | - uses: actions/setup-node@v4 |
28 | | - with: |
29 | | - node-version: lts/* |
30 | | - cache: 'pnpm' |
31 | | - |
32 | | - - name: Install dependencies |
33 | | - run: pnpm install |
34 | | - |
35 | | - - name: Build assets |
36 | | - run: pnpm build |
37 | | - |
38 | | - - name: Install PHP |
39 | | - uses: shivammathur/setup-php@v2 |
40 | | - with: |
41 | | - php-version: 'latest' |
42 | | - |
43 | | - - name: Install Composer |
44 | | - uses: ramsey/composer-install@v3 |
45 | | - |
46 | | - - name: Downgrade PHP code to the minimum version WordPress requires |
47 | | - run: vendor/bin/rector --ansi |
48 | | - |
49 | | - - name: Validate PHP syntax to prevent fatal errors |
50 | | - run: find . -name "*.php" -type f -not \( -path "./vendor/*" -o -path "./node_modules/*" \) -print0 | xargs -0 -n1 php -l |
51 | | - |
52 | | - - name: Install jq |
53 | | - run: sudo apt-get install -y jq |
54 | | - |
55 | | - - name: Run release.sh script |
56 | | - id: script |
57 | | - shell: bash |
58 | | - run: | |
59 | | - chmod +x ./release.sh |
60 | | - ./release.sh |
61 | | -
|
62 | | - - name: Commit and push changes |
63 | | - if: steps.script.outputs.has-changed == 'true' |
64 | | - run: | |
65 | | - git config user.name "GitHub Actions" |
66 | | - git config user.email "[email protected]" |
67 | | - git add . |
68 | | - git commit -m "${{ steps.script.outputs.release-name }}" |
69 | | - # Push changes, handling potential conflicts |
70 | | - git push || git pull --rebase origin ${{ github.ref_name }} && git push |
71 | | -
|
72 | | - - name: Create release |
73 | | - id: release |
74 | | - if: steps.script.outputs.has-changed == 'true' |
75 | | - uses: actions/create-release@v1 |
76 | | - env: |
77 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
78 | | - with: |
79 | | - tag_name: ${{ steps.script.outputs.stable-tag }} |
80 | | - release_name: ${{ steps.script.outputs.release-name }} |
81 | | - body: ${{ steps.script.outputs.release-body }} |
82 | | - draft: false |
83 | | - prerelease: false |
84 | | - |
85 | | - - name: WordPress Plugin Deploy |
86 | | - if: steps.script.outputs.has-changed == 'true' |
87 | | - id: deploy |
88 | | - |
89 | | - with: |
90 | | - generate-zip: true |
91 | | - env: |
92 | | - SVN_USERNAME: ${{ secrets.SVN_USERNAME }} |
93 | | - SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} |
94 | | - SLUG: simpleanalytics |
95 | | - VERSION: ${{ steps.script.outputs.stable-tag }} |
96 | | - ASSETS_DIR: assets |
97 | | - |
98 | | - - name: Upload release asset |
99 | | - if: steps.script.outputs.has-changed == 'true' |
100 | | - |
101 | | - env: |
102 | | - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
103 | | - with: |
104 | | - upload_url: ${{ steps.release.outputs.upload_url }} |
105 | | - asset_path: ${{ steps.deploy.outputs.zip-path }} |
106 | | - asset_name: ${{ github.event.repository.name }}.zip |
107 | | - asset_content_type: application/zip |
| 9 | + update: |
| 10 | + name: Update version |
| 11 | + runs-on: ubuntu-latest |
| 12 | + timeout-minutes: 10 |
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Check out repository |
| 16 | + uses: actions/checkout@v3 |
| 17 | + with: |
| 18 | + fetch-depth: 0 # Fetch all history so we can access tags and commits |
| 19 | + fetch-tags: true # Ensure tags are fetched |
| 20 | + |
| 21 | + - name: Install pnpm |
| 22 | + uses: pnpm/action-setup@v4 |
| 23 | + with: |
| 24 | + version: 9 |
| 25 | + |
| 26 | + - name: Install Node.js LTS |
| 27 | + uses: actions/setup-node@v4 |
| 28 | + with: |
| 29 | + node-version: lts/* |
| 30 | + cache: "pnpm" |
| 31 | + |
| 32 | + - name: Install dependencies |
| 33 | + run: pnpm install |
| 34 | + |
| 35 | + - name: Build assets |
| 36 | + run: pnpm build |
| 37 | + |
| 38 | + - name: Install PHP |
| 39 | + uses: shivammathur/setup-php@v2 |
| 40 | + with: |
| 41 | + php-version: "latest" |
| 42 | + |
| 43 | + - name: Install Composer |
| 44 | + uses: ramsey/composer-install@v3 |
| 45 | + |
| 46 | + - name: Downgrade PHP code to the minimum version WordPress requires |
| 47 | + run: vendor/bin/rector --ansi |
| 48 | + |
| 49 | + - name: Validate PHP syntax to prevent fatal errors |
| 50 | + run: find . -name "*.php" -type f -not \( -path "./vendor/*" -o -path "./node_modules/*" \) -print0 | xargs -0 -n1 php -l |
| 51 | + |
| 52 | + - name: Install jq |
| 53 | + run: sudo apt-get install -y jq |
| 54 | + |
| 55 | + - name: Run release.sh script |
| 56 | + id: script |
| 57 | + shell: bash |
| 58 | + run: | |
| 59 | + chmod +x ./release.sh |
| 60 | + ./release.sh |
| 61 | +
|
| 62 | + - name: Commit and push changes |
| 63 | + if: steps.script.outputs.has-changed == 'true' |
| 64 | + run: | |
| 65 | + git config user.name "GitHub Actions" |
| 66 | + git config user.email "[email protected]" |
| 67 | + git add . |
| 68 | + git commit -m "${{ steps.script.outputs.release-name }}" |
| 69 | + # Push changes, handling potential conflicts |
| 70 | + git push || git pull --rebase origin ${{ github.ref_name }} && git push |
| 71 | +
|
| 72 | + - name: Create release |
| 73 | + id: release |
| 74 | + if: steps.script.outputs.has-changed == 'true' |
| 75 | + uses: actions/create-release@v1 |
| 76 | + env: |
| 77 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + with: |
| 79 | + tag_name: ${{ steps.script.outputs.stable-tag }} |
| 80 | + release_name: ${{ steps.script.outputs.release-name }} |
| 81 | + body: ${{ steps.script.outputs.release-body }} |
| 82 | + draft: false |
| 83 | + prerelease: false |
| 84 | + |
| 85 | + - name: WordPress Plugin Deploy |
| 86 | + if: steps.script.outputs.has-changed == 'true' |
| 87 | + id: deploy |
| 88 | + |
| 89 | + with: |
| 90 | + generate-zip: true |
| 91 | + env: |
| 92 | + SVN_USERNAME: ${{ secrets.SVN_USERNAME }} |
| 93 | + SVN_PASSWORD: ${{ secrets.SVN_PASSWORD }} |
| 94 | + SLUG: simpleanalytics |
| 95 | + VERSION: ${{ steps.script.outputs.stable-tag }} |
| 96 | + ASSETS_DIR: assets |
| 97 | + |
| 98 | + - name: Upload release asset |
| 99 | + if: steps.script.outputs.has-changed == 'true' |
| 100 | + |
| 101 | + env: |
| 102 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 103 | + with: |
| 104 | + upload_url: ${{ steps.release.outputs.upload_url }} |
| 105 | + asset_path: ${{ steps.deploy.outputs.zip-path }} |
| 106 | + asset_name: ${{ github.event.repository.name }}.zip |
| 107 | + asset_content_type: application/zip |
0 commit comments