|
7 | 7 | - develop |
8 | 8 | workflow_dispatch: |
9 | 9 |
|
10 | | -env: |
11 | | - AMO_CLIENT_ID: ${{ secrets.AMO_CLIENT_ID }} |
12 | | - AMO_CLIENT_SECRET: ${{ secrets.AMO_CLIENT_SECRET }} |
13 | | - AMO_REDIRECT_URL: ${{ secrets.AMO_REDIRECT_URL }} |
| 10 | +permissions: |
| 11 | + contents: write |
| 12 | + packages: write |
14 | 13 |
|
15 | 14 | jobs: |
16 | | - build: |
17 | | - uses: mikopbx/.github-workflows/.github/workflows/extension-publish.yml@master |
18 | | - with: |
19 | | - initial_version: "1.84" |
20 | | - custom_build_steps: | |
21 | | - cd module |
22 | | - sed -i "s|%CLIENT_ID%|${{ env.AMO_CLIENT_ID }}|g" Lib/AmoCrmMainBase.php |
23 | | - sed -i "s|%CLIENT_SECRET%|${{ env.AMO_CLIENT_SECRET }}|g" Lib/AmoCrmMainBase.php |
24 | | - sed -i "s|%REDIRECT_URL%|${{ env.AMO_REDIRECT_URL }}|g" Lib/AmoCrmMainBase.php |
25 | | - echo "AmoCrmMainBase.php placeholders replaced." |
26 | | - WIDGET_VERSION="1.0.$(git rev-list --count HEAD)" |
27 | | - sed -i "s|%WidgetVersion%|$WIDGET_VERSION|g" widget/manifest.json |
28 | | - sed -i "s|%WidgetVersion%|$WIDGET_VERSION|g" widget/script.js |
29 | | - cd widget && zip -r "$RUNNER_TEMP/widget.zip" . -x "*.DS_Store*" && cd .. |
30 | | - echo "Widget built: widget.zip (version $WIDGET_VERSION)" |
31 | | - rm -rf widget |
32 | | - echo "widget/ removed from module archive." |
33 | | - secrets: inherit |
34 | | - |
35 | | - upload-widget: |
36 | | - needs: build |
| 15 | + build-and-publish: |
37 | 16 | runs-on: ubuntu-latest |
38 | | - permissions: |
39 | | - contents: write |
40 | 17 | steps: |
41 | | - - uses: actions/checkout@v4 |
| 18 | + - name: Checkout module repository |
| 19 | + uses: actions/checkout@v4 |
42 | 20 | with: |
43 | 21 | fetch-depth: 0 |
| 22 | + path: module |
| 23 | + |
| 24 | + - name: Checkout workflows repository |
| 25 | + uses: actions/checkout@v4 |
| 26 | + with: |
| 27 | + repository: mikopbx/.github-workflows |
| 28 | + path: .github-workflows |
| 29 | + |
| 30 | + - name: Validate module configuration |
| 31 | + id: validate |
| 32 | + uses: ./.github-workflows/.github/actions/validate |
| 33 | + |
| 34 | + - name: Manage versions |
| 35 | + id: version |
| 36 | + uses: ./.github-workflows/.github/actions/versioning |
| 37 | + with: |
| 38 | + initial_version: "1.84" |
| 39 | + |
| 40 | + - name: Setup build environment |
| 41 | + uses: ./.github-workflows/.github/actions/docker-build |
| 42 | + with: |
| 43 | + php_version: ${{ steps.validate.outputs.php_version }} |
| 44 | + |
| 45 | + - name: Handle dependencies |
| 46 | + uses: ./.github-workflows/.github/actions/composer |
| 47 | + with: |
| 48 | + php_version: ${{ steps.validate.outputs.php_version }} |
| 49 | + |
| 50 | + - name: Cache Docker images |
| 51 | + uses: actions/cache@v3 |
| 52 | + id: docker-cache |
| 53 | + with: |
| 54 | + path: ${{ runner.temp }}/docker-cache-*.tar |
| 55 | + key: ${{ runner.os }}-docker-${{ hashFiles('module/**/Dockerfile') }} |
| 56 | + restore-keys: | |
| 57 | + ${{ runner.os }}-docker- |
| 58 | +
|
| 59 | + - name: Replace OAuth placeholders |
| 60 | + env: |
| 61 | + AMO_CLIENT_ID: ${{ secrets.AMO_CLIENT_ID }} |
| 62 | + AMO_CLIENT_SECRET: ${{ secrets.AMO_CLIENT_SECRET }} |
| 63 | + AMO_REDIRECT_URL: ${{ secrets.AMO_REDIRECT_URL }} |
| 64 | + run: | |
| 65 | + cd module |
| 66 | + sed -i "s|%CLIENT_ID%|$AMO_CLIENT_ID|g" Lib/AmoCrmMainBase.php |
| 67 | + sed -i "s|%CLIENT_SECRET%|$AMO_CLIENT_SECRET|g" Lib/AmoCrmMainBase.php |
| 68 | + sed -i "s|%REDIRECT_URL%|$AMO_REDIRECT_URL|g" Lib/AmoCrmMainBase.php |
| 69 | + echo "AmoCrmMainBase.php placeholders replaced." |
44 | 70 |
|
45 | 71 | - name: Build widget |
46 | 72 | run: | |
| 73 | + cd module |
47 | 74 | WIDGET_VERSION="1.0.$(git rev-list --count HEAD)" |
48 | 75 | sed -i "s|%WidgetVersion%|$WIDGET_VERSION|g" widget/manifest.json |
49 | 76 | sed -i "s|%WidgetVersion%|$WIDGET_VERSION|g" widget/script.js |
50 | | - cd widget && zip -r ../widget.zip . -x "*.DS_Store*" |
| 77 | + cd widget && zip -r "$RUNNER_TEMP/widget.zip" . -x "*.DS_Store*" && cd .. |
| 78 | + echo "Widget built: widget.zip (version $WIDGET_VERSION)" |
| 79 | + rm -rf widget |
| 80 | + echo "widget/ removed from module archive." |
| 81 | +
|
| 82 | + - name: Sync translations from Core |
| 83 | + uses: ./.github-workflows/.github/actions/sync-translations |
| 84 | + |
| 85 | + - name: Create module package |
| 86 | + id: archive |
| 87 | + uses: ./.github-workflows/.github/actions/archive |
| 88 | + with: |
| 89 | + version: ${{ steps.version.outputs.new_version }} |
| 90 | + |
| 91 | + - name: Generate changelog |
| 92 | + id: changelog |
| 93 | + if: steps.validate.outputs.changelog_enabled == 'true' |
| 94 | + uses: ./.github-workflows/.github/actions/changelog |
| 95 | + |
| 96 | + - name: Publish module |
| 97 | + if: | |
| 98 | + github.ref == 'refs/heads/master' && |
| 99 | + steps.validate.outputs.publish_release == 'true' |
| 100 | + env: |
| 101 | + OWNCLOUD_AUTH: ${{ secrets.OWNCLOUD_AUTH }} |
| 102 | + WEBDAV_ROOT: ${{ secrets.WEBDAV_ROOT }} |
| 103 | + SHARE_API_URL: ${{ secrets.SHARE_API_URL }} |
| 104 | + MIKO_LIC_REST_VENDOR_ID: ${{ secrets.MIKO_LIC_REST_VENDOR_ID }} |
| 105 | + MIKO_LIC_REST_API_KEY: ${{ secrets.MIKO_LIC_REST_API_KEY }} |
| 106 | + MIKO_LIC_HOSTNAME: ${{ secrets.MIKO_LIC_HOSTNAME }} |
| 107 | + uses: ./.github-workflows/.github/actions/publish |
| 108 | + with: |
| 109 | + php_version: ${{ steps.validate.outputs.php_version }} |
| 110 | + module_filename: ${{ steps.archive.outputs.filename }} |
| 111 | + version: ${{ steps.version.outputs.new_version }} |
| 112 | + changelog: ${{ steps.changelog.outputs.changelog }} |
| 113 | + |
| 114 | + - name: Manage GitHub releases |
| 115 | + if: steps.validate.outputs.create_github_release == 'true' |
| 116 | + uses: ./.github-workflows/.github/actions/release |
| 117 | + with: |
| 118 | + version: ${{ steps.version.outputs.new_version }} |
| 119 | + version_tag: ${{ steps.version.outputs.new_version_tag }} |
| 120 | + module_filename: ${{ steps.archive.outputs.filename }} |
| 121 | + changelog: ${{ steps.changelog.outputs.changelog }} |
51 | 122 |
|
52 | | - - name: Upload widget to GitHub release |
| 123 | + - name: Upload widget to release |
| 124 | + if: steps.validate.outputs.create_github_release == 'true' |
53 | 125 | env: |
54 | 126 | GH_TOKEN: ${{ github.token }} |
55 | 127 | run: | |
56 | | - TAG=$(gh release list --limit 1 --json tagName -q '.[0].tagName') |
57 | | - if [ -n "$TAG" ]; then |
58 | | - gh release upload "$TAG" widget.zip --clobber |
| 128 | + TAG="${{ steps.version.outputs.new_version_tag }}" |
| 129 | + if [ -n "$TAG" ] && gh release view "$TAG" &>/dev/null; then |
| 130 | + gh release upload "$TAG" "$RUNNER_TEMP/widget.zip" --clobber |
59 | 131 | echo "widget.zip uploaded to release $TAG" |
60 | 132 | else |
61 | | - echo "No release found, skipping upload." |
| 133 | + echo "Release $TAG not found, skipping widget upload." |
62 | 134 | fi |
0 commit comments