-
Notifications
You must be signed in to change notification settings - Fork 3
202 lines (173 loc) · 6.75 KB
/
build-release-publish.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
name: Release and publish
on:
release:
types: [released, prereleased]
jobs:
build:
name: Build the base artifact
runs-on: ubuntu-latest
outputs:
version: ${{ steps.set_version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v2.0.0
- name: Setup node env 🏗
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
scope: '@prestashopcorp'
- name: Set version
id: set_version
run: |
echo "version=$(echo "${{ github.event.release.tag_name }}" | sed 's/^v//' | cut -d'-' -f1)" >> "$GITHUB_OUTPUT"
- name: Bump version
run: |
VERSION=${{ steps.set_version.outputs.version }} \
make version
# - name: Install composer dependencies
# run: composer install --no-dev -o
- name: Scoped dependencies
run: make php-scoper
- name: Get yarn cache directory path 🛠
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"
working-directory: ./_dev
- name: Cache node_modules 📦
uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Install _dev dependencies 👨🏻💻
working-directory: ./_dev
run: yarn --frozen-lockfile --silent
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN_RO }}
- name: Build apps
working-directory: ./_dev
run: yarn build
# - name: Clean-up project
# uses: PrestaShopCorp/github-action-clean-before-deploy@v1.0
- name: Clean-up project 🧹
run: |
rm -rf .git
rm -rf _dev
- name: Create & upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: ${{ github.workspace }}
include-hidden-files: true
upload_release_asset_production:
name: Upload the production zip asset to the release
runs-on: ubuntu-latest
needs: build
outputs:
zip_file: ${{ steps.set_zip_file.outputs.zip_file }}
steps:
- name: Set the zip file
id: set_zip_file
run: |
echo "zip_file=${{ github.event.repository.name }}-${{ needs.build.outputs.version }}.zip" >> "$GITHUB_ENV"
echo "zip_file=${{ github.event.repository.name }}-${{ needs.build.outputs.version }}.zip" >> "$GITHUB_OUTPUT"
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: ${{ github.workspace }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ secrets.GCLOUD_PROJECT_PRODUCTION }}
service_account_key: ${{ secrets.G_CREDENTIAL_PRODUCTION }}
export_default_credentials: true
- name: Copy env files
run: |
gcloud components install beta
gcloud beta secrets versions access latest --secret="accounts-module-config" > ${{ github.workspace }}/config/config.yml
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.G_CREDENTIAL_PRODUCTION }}
- name: Prepare the production zip
run: |
cd ${{ github.workspace }}
sh ./scripts/bundle-module.sh ${{ env.zip_file }}
env:
ENV_FILE: ${{ secrets.PS_ACCOUNTS_ENV_PROD }}
- name: Publish the production zip
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ github.workspace }}/dist/${{ env.zip_file }}
asset_name: ${{ env.zip_file }}
asset_content_type: application/zip
upload_release_asset_preprod:
name: Upload the preprod zip asset to the release
runs-on: ubuntu-latest
needs: build
steps:
- name: Set the zip file
id: set_zip_file
run: |
echo "zip_file=${{ github.event.repository.name }}_preprod-${{ needs.build.outputs.version }}.zip" >> "$GITHUB_ENV"
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: ${{ github.event.repository.name }}
path: ${{ github.workspace }}
- name: Set up Cloud SDK
uses: google-github-actions/setup-gcloud@v0
with:
project_id: ${{ secrets.GCLOUD_PROJECT_PREPROD }}
service_account_key: ${{ secrets.G_CREDENTIAL_PREPROD }}
export_default_credentials: true
- name: Copy env files
run: |
gcloud components install beta
gcloud beta secrets versions access latest --secret="accounts-module-config" > ${{ github.workspace }}/config/config.yml
env:
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.G_CREDENTIAL_PREPROD }}
- name: Prepare the preprod zip
run: |
cd ${{ github.workspace }}
sh ./scripts/bundle-module.sh ${{ env.zip_file }}
- name: Publish the preprod zip
uses: actions/upload-release-asset@v1.0.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ${{ github.workspace }}/dist/${{ env.zip_file }}
asset_name: ${{ env.zip_file }}
asset_content_type: application/zip
publish_to_marketplace:
name: Publish the module to the addons marketplace
runs-on: ubuntu-latest
needs: upload_release_asset_production
if: "!github.event.release.prerelease"
steps:
- name: Checkout
uses: actions/checkout@v2.0.0
- name: Download release asset
uses: dsaltares/fetch-gh-release-asset@0.06
with:
repo: ${{ github.event.repository.full_name }}
version: ${{ github.event.release.id }}
file: ${{ needs.upload_release_asset_production.outputs.zip_file }}
token: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare publishing tool
run: |
composer global require prestashop/publish-on-marketplace
- name: Release zip
run: |
~/.composer/vendor/bin/publish-on-marketplace \
--archive=$PWD/${{ needs.upload_release_asset_production.outputs.zip_file }} \
--metadata-json=$PWD/.github/mktp-metadata.json \
--changelog="${{ github.event.release.body }}" \
--debug
env:
MARKETPLACE_API_KEY: ${{ secrets.MARKETPLACE_API_KEY }}