|
1 | 1 | name: Release Plugin
|
2 |
| - |
3 | 2 | on:
|
4 | 3 | push:
|
5 | 4 | tags:
|
|
10 | 9 | name: New release
|
11 | 10 | runs-on: ubuntu-latest
|
12 | 11 | steps:
|
13 |
| - - name: Checkout code |
14 |
| - uses: actions/checkout@v3 # Updated to latest version |
15 |
| - |
16 |
| - - name: Setup |
17 |
| - env: |
18 |
| - WORDPRESS_ORG_SLUG: ${{ vars.WORDPRESS_ORG_SLUG }} |
19 |
| - WHITELABEL: ${{ vars.WHITELABEL_NAME }} |
20 |
| - FAQ_ENTRIES: ${{ vars.FAQ_ENTRIES }} |
21 |
| - FEATURES: ${{ vars.FEATURES }} |
22 |
| - run: | |
23 |
| - echo $GITHUB_WORKSPACE |
24 |
| - echo $WORDPRESS_ORG_SLUG |
25 |
| - ls -ltrh |
26 |
| - git clone https://github.com/squizlabs/PHP_CodeSniffer.git phpcs |
27 |
| - git clone -b main https://github.com/WordPress/WordPress-Coding-Standards.git wpcs |
28 |
| - cd phpcs |
29 |
| - ./bin/phpcs --config-set installed_paths ../wpcs |
30 |
| - cd ../ |
31 |
| - ls -ltrh |
32 |
| - pwd |
33 |
| - mkdir -p $GITHUB_WORKSPACE/build-woo/src |
34 |
| - rsync -r --exclude 'build-woo' --exclude 'wpcs' --exclude 'phpcs' --exclude '.git' --exclude '.github' --exclude '.travis.yml' --exclude 'README.md' . $GITHUB_WORKSPACE/build-woo/src |
35 |
| - perl -plne 'print "$ENV{'FEATURES'}" if(/== Installation ==/); print "$ENV{'FAQ_ENTRIES'}" if(/== Changelog ==/);' $GITHUB_WORKSPACE/build-woo/src/readme.txt > $GITHUB_WORKSPACE/build-woo/src/readme_mod.txt |
36 |
| - mv build-woo/src/readme_mod.txt build-woo/src/readme.txt |
37 |
| - mkdir build-woo/$WORDPRESS_ORG_SLUG |
38 |
| - rsync -r build-woo/src/ build-woo/$WORDPRESS_ORG_SLUG/ |
39 |
| -
|
40 |
| - - name: Zip & Sniff |
41 |
| - env: |
42 |
| - WORDPRESS_ORG_SLUG: ${{ vars.WORDPRESS_ORG_SLUG }} |
43 |
| - WHITELABEL: ${{ vars.WHITELABEL_NAME }} |
44 |
| - run: | |
45 |
| - ls -ltrh |
46 |
| - cd $GITHUB_WORKSPACE/build-woo/ |
47 |
| - zip -r $GITHUB_WORKSPACE/${{ env.WORDPRESS_ORG_SLUG }}.zip ${{ env.WORDPRESS_ORG_SLUG }} |
48 |
| - rm -rf src/docs |
49 |
| - ../phpcs/bin/phpcbf -n --standard=WordPress src/ --ignore=/src/$WHITELABEL-sdk || true |
50 |
| - ../phpcs/bin/phpcs -n --standard=WordPress src/ --ignore=/src/$WHITELABEL-sdk || true |
51 |
| -
|
52 |
| - - name: Check if Release Exists |
53 |
| - id: check_release |
54 |
| - run: | |
55 |
| - response=$(curl -s -o response.json -w "%{http_code}" -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/tags/${{ github.ref_name }}) |
56 |
| - if [ "$response" = "200" ]; then |
57 |
| - echo "release_exists=true" >> $GITHUB_ENV |
58 |
| - else |
59 |
| - echo "release_exists=false" >> $GITHUB_ENV |
60 |
| - fi |
| 12 | + - name: Checkout code |
| 13 | + uses: actions/checkout@v2 |
61 | 14 |
|
62 |
| - - name: Create or Update GitHub Release |
63 |
| - id: create_or_update_release |
64 |
| - if: env.release_exists == 'false' |
65 |
| - uses: softprops/action-gh-release@v1 # Updated to a more flexible action |
66 |
| - env: |
67 |
| - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
68 |
| - with: |
69 |
| - tag_name: ${{ github.ref_name }} |
70 |
| - name: Release ${{ github.ref_name }} |
71 |
| - files: ${{ github.workspace }}/${{ env.WORDPRESS_ORG_SLUG }}.zip |
72 |
| - overwrite: true |
| 15 | + - name: Setup |
| 16 | + env: |
| 17 | + WORDPRESS_ORG_SLUG: ${{ vars.WORDPRESS_ORG_SLUG }} |
| 18 | + WHITELABEL: ${{ vars.WHITELABEL_NAME }} |
| 19 | + FAQ_ENTRIES: ${{ vars.FAQ_ENTRIES }} |
| 20 | + FEATURES: ${{ vars.FEATURES }} |
| 21 | + run: | |
| 22 | + echo $GITHUB_WORKSPACE |
| 23 | + echo $WORDPRESS_ORG_SLUG |
| 24 | + ls -ltrh |
| 25 | + git clone https://github.com/squizlabs/PHP_CodeSniffer.git phpcs; |
| 26 | + git clone -b main https://github.com/WordPress/WordPress-Coding-Standards.git wpcs; |
| 27 | + cd phpcs; |
| 28 | + ./bin/phpcs --config-set installed_paths ../wpcs; |
| 29 | + cd ../; |
| 30 | + ls -ltrh |
| 31 | + pwd |
| 32 | + mkdir -p $GITHUB_WORKSPACE/build-woo/src; |
| 33 | + rsync -r --exclude 'build-woo' --exclude 'wpcs' --exclude 'phpcs' --exclude '.git' --exclude '.github' --exclude '.travis.yml' --exclude 'README.md' . $GITHUB_WORKSPACE/build-woo/src; |
| 34 | + perl -plne 'print "$ENV{'FEATURES'}" if(/== Installation ==/); print "$ENV{'FAQ_ENTRIES'}" if(/== Changelog ==/);' $GITHUB_WORKSPACE/build-woo/src/readme.txt > $GITHUB_WORKSPACE/build-woo/src/readme_mod.txt; |
| 35 | + mv build-woo/src/readme_mod.txt build-woo/src/readme.txt; |
| 36 | + mkdir build-woo/$WORDPRESS_ORG_SLUG; |
| 37 | + rsync -r build-woo/src/ build-woo/$WORDPRESS_ORG_SLUG/; |
73 | 38 |
|
74 |
| - - name: Update GitHub Release Assets |
75 |
| - if: env.release_exists == 'true' |
76 |
| - run: | |
77 |
| - release_id=$(jq '.id' response.json) |
78 |
| - asset_id=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/${release_id}/assets | jq -r '.[] | select(.name == "'${{ env.WORDPRESS_ORG_SLUG }}.zip'") | .id') |
79 |
| - if [ -n "$asset_id" ]; then |
80 |
| - curl -X DELETE -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" https://api.github.com/repos/${{ github.repository }}/releases/assets/${asset_id} |
81 |
| - fi |
82 |
| - curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" -H "Content-Type: application/zip" --data-binary @$GITHUB_WORKSPACE/${{ env.WORDPRESS_ORG_SLUG }}.zip "https://uploads.github.com/repos/${{ github.repository }}/releases/${release_id}/assets?name=${{ env.WORDPRESS_ORG_SLUG }}.zip" |
| 39 | + - name: Zip & Sniff |
| 40 | + env: |
| 41 | + WORDPRESS_ORG_SLUG: ${{ vars.WORDPRESS_ORG_SLUG }} |
| 42 | + WHITELABEL: ${{ vars.WHITELABEL_NAME }} |
| 43 | + run: | |
| 44 | + ls -ltrh; |
| 45 | + cd $GITHUB_WORKSPACE/build-woo/ |
| 46 | + zip -r $GITHUB_WORKSPACE/$WORDPRESS_ORG_SLUG.zip $WORDPRESS_ORG_SLUG; |
| 47 | + rm -rf src/docs; |
| 48 | + ../phpcs/bin/phpcbf -n --standard=WordPress src/ --ignore=/src/$WHITELABEL-sdk || true; |
| 49 | + ../phpcs/bin/phpcs -n --standard=WordPress src/ --ignore=/src/$WHITELABEL-sdk || true; |
83 | 50 |
|
| 51 | + - name: Upload binaries to Github release |
| 52 | + uses: svenstaro/upload-release-action@v2 |
| 53 | + with: |
| 54 | + repo_token: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + file: ${{ vars.WORDPRESS_ORG_SLUG }}.zip |
| 56 | + asset_name: ${{ vars.WORDPRESS_ORG_SLUG }} |
| 57 | + tag: ${{ github.ref }} |
84 | 58 |
|
85 | 59 | # - name: WordPress Plugin Deploy
|
86 | 60 | # id: deploy
|
|
0 commit comments