|
| 1 | +# This is a basic workflow to help you get started with Actions |
| 2 | + |
| 3 | +name: bcc-keep-translated-posts-status-same-as-original plugin |
| 4 | + |
| 5 | +# Controls when the workflow will run |
| 6 | +on: |
| 7 | + # Triggers the workflow on push or pull request events but only for the master branch |
| 8 | + push: |
| 9 | + branches: [ master ] |
| 10 | + paths: |
| 11 | + - plugins/bcc-keep-translated-posts-status-same-as-original/** |
| 12 | + - .github/workflows/bcc-keep-translated-posts-status-same-as-original-plugin-release.yml |
| 13 | + tags-ignore: |
| 14 | + - '**' |
| 15 | + pull_request: |
| 16 | + branches: [ master ] |
| 17 | + paths: |
| 18 | + - plugins/bcc-keep-translated-posts-status-same-as-original/** |
| 19 | + - .github/workflows/bcc-keep-translated-posts-status-same-as-original-plugin-release.yml |
| 20 | + tags-ignore: |
| 21 | + - '**' |
| 22 | + |
| 23 | + # Allows you to run this workflow manually from the Actions tab |
| 24 | + workflow_dispatch: |
| 25 | + |
| 26 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 27 | +jobs: |
| 28 | + # This workflow contains a single job called "build" |
| 29 | + build: |
| 30 | + # The type of runner that the job will run on |
| 31 | + runs-on: ubuntu-latest |
| 32 | + |
| 33 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 34 | + steps: |
| 35 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 36 | + - uses: actions/checkout@v2 |
| 37 | + |
| 38 | + - name: Get Package Version |
| 39 | + id: version |
| 40 | + uses: notiz-dev/github-action-json-property@release |
| 41 | + with: |
| 42 | + path: 'plugins/bcc-keep-translated-posts-status-same-as-original/package.json' |
| 43 | + prop_path: 'version' |
| 44 | + |
| 45 | + - name: Get Previous Updated |
| 46 | + id: lastupdated |
| 47 | + uses: notiz-dev/github-action-json-property@release |
| 48 | + with: |
| 49 | + path: 'plugins/bcc-keep-translated-posts-status-same-as-original/package.json' |
| 50 | + prop_path: 'last_updated' |
| 51 | + |
| 52 | + # Runs a set of commands using the runners shell |
| 53 | + - id: build-and-zip |
| 54 | + name: Build and Zip Plugin |
| 55 | + run: | |
| 56 | + # Build javascript |
| 57 | + yarn install --frozen-lockfile |
| 58 | + cd plugins/bcc-keep-translated-posts-status-same-as-original |
| 59 | + yarn build |
| 60 | +
|
| 61 | + # Get package version |
| 62 | + package_version=${{steps.version.outputs.prop}} |
| 63 | + previous_date="${{steps.lastupdated.outputs.prop}}" |
| 64 | + current_date=$(date -u +'%Y-%m-%d %H:%M:%S') |
| 65 | + |
| 66 | + build_version="$(echo $package_version | sed -re 's/([0-9]+\.[0-9]+\.)[0-9]+/\1/')${GITHUB_RUN_NUMBER}" |
| 67 | + |
| 68 | + |
| 69 | + sed -i "s|$package_version|$build_version|g" package.json |
| 70 | + sed -i "s|$previous_date|$current_date|g" package.json |
| 71 | + sed -i "s|<VERSION>|$build_version|g" bcc-keep-translated-posts-status-same-as-original.php |
| 72 | + sed -i "s|$package_version|$build_version|g" bcc-keep-translated-posts-status-same-as-original.php |
| 73 | + |
| 74 | + |
| 75 | + git config user.name "bcc-bot" |
| 76 | + git config user.email "<>" |
| 77 | + git tag "version-bump-v${build_version}" |
| 78 | + git commit -am "Released bcc-keep-translated-posts-status-same-as-original plugin v${build_version}" |
| 79 | + git push |
| 80 | + |
| 81 | + cd .. |
| 82 | + zip -r bcc-keep-translated-posts-status-same-as-original.zip bcc-keep-translated-posts-status-same-as-original |
| 83 | + cd .. |
| 84 | + |
| 85 | + echo "::set-output name=tag_name::bcc-keep-translated-posts-status-same-as-original-v${build_version}" |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + - uses: ncipollo/release-action@v1 |
| 90 | + name: Create Release |
| 91 | + with: |
| 92 | + artifacts: "plugins/bcc-keep-translated-posts-status-same-as-original.zip" |
| 93 | + tag: ${{steps.build-and-zip.outputs.tag_name}} |
| 94 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 95 | + |
0 commit comments