|
| 1 | +# Workflow Document: https://help.github.com/en/articles/workflow-syntax-for-github-actions |
| 2 | + |
| 3 | +# This workflow detects a tag push to Github, it will automatically upload the package to github releases. |
1 | 4 | name: release |
2 | 5 |
|
| 6 | +# see: https://help.github.com/en/articles/workflow-syntax-for-github-actions#on |
3 | 7 | on: |
4 | 8 | create: |
5 | | - tags: |
| 9 | + tags: [] |
| 10 | + # - v*.*.* # to use filters. wildcard characters supported. |
6 | 11 |
|
| 12 | +# https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobs |
7 | 13 | jobs: |
8 | 14 | release: |
9 | 15 | name: Release |
| 16 | + |
| 17 | + # https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idruns-on |
10 | 18 | runs-on: ubuntu-latest |
| 19 | + |
| 20 | + # https://help.github.com/en/articles/workflow-syntax-for-github-actions#jobsjob_idsteps |
11 | 21 | steps: |
| 22 | + |
| 23 | + # [official action] clone code to workspace |
| 24 | + # https://github.com/actions/checkout |
12 | 25 | - uses: actions/checkout@v1 |
| 26 | + |
| 27 | + |
| 28 | + # install modules by composer. remove this step it if no needed. |
13 | 29 | - name: composer install |
14 | 30 | run: composer install |
| 31 | + |
| 32 | + # install modules by npm. |
| 33 | + # - name: npm clean install |
| 34 | + # run: npm ci |
| 35 | + |
| 36 | + # remove this step if you want to update the version manually. |
| 37 | + # NOTICE: ref_type exists only for events of type create. see https://developer.github.com/v3/activity/events/types/#createevent |
15 | 38 | - name: add version |
| 39 | + env: |
| 40 | + PACKAGE_NAME: "shifter-github-hosting-plugin-sample" |
16 | 41 | run: | |
| 42 | + # retrieve tag and replase version number in file. |
17 | 43 | export CREATE_EVENT_REF_TYPE=$(jq --raw-output .ref_type "$GITHUB_EVENT_PATH") |
18 | 44 | export TAGNAME=$(jq --raw-output .ref "$GITHUB_EVENT_PATH") |
19 | | - sed -i -e "s/{release version}/${TAGNAME}/g" shifter-github-hosting-plugin-sample.php |
| 45 | + sed -i -e "s/{release version}/${TAGNAME}/g" ${PACKAGE_NAME}.php |
| 46 | +
|
| 47 | + # create zip acrive for install to WordPress. |
| 48 | + # please edit FILES_TO_ARCIVE to suit your project. |
20 | 49 | - name: create archive |
21 | | - run: zip -r shifter-github-hosting-plugin-sample.zip *.php *.md vendor/* |
22 | | - - name: upload |
23 | 50 | env: |
| 51 | + PACKAGE_NAME: "shifter-github-hosting-plugin-sample" |
| 52 | + FILES_TO_ARCIVE: "*.php *.md vendor/*" |
| 53 | + run: zip -r ${PACKAGE_NAME}.zip ${FILES_TO_ARCIVE} |
| 54 | + |
| 55 | + # upload zip arvive by ghr. |
| 56 | + # `secrets.GITHUB_TOKEN` for using ghr is issued temporarily when executing action. No special settings are required. |
| 57 | + # ghr - Easily ship your project to your user using Github Releases : https://deeeet.com/ghr/ |
| 58 | + - name: upload to github release |
| 59 | + env: |
| 60 | + PACKAGE_NAME: "shifter-github-hosting-plugin-sample" |
24 | 61 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
25 | 62 | GOPATH: /home/runner/go |
26 | 63 | run: | |
| 64 | + # retrieve tag and replase version number in file. |
27 | 65 | export CREATE_EVENT_REF_TYPE=$(jq --raw-output .ref_type "$GITHUB_EVENT_PATH") |
28 | 66 | export TAGNAME=$(jq --raw-output .ref "$GITHUB_EVENT_PATH") |
| 67 | + # install ghr, then upload archve. |
29 | 68 | go get -u github.com/tcnksm/ghr |
30 | | - ${GOPATH}/bin/ghr -replace ${TAGNAME} shifter-github-hosting-plugin-sample.zip |
| 69 | + ${GOPATH}/bin/ghr -b "${PACKAGE_NAME} ${TAGNAME}" -replace ${TAGNAME} ${PACKAGE_NAME}.zip |
0 commit comments