Release and publish #199
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Release and publish | |
on: | |
release: | |
types: [released, prereleased] | |
jobs: | |
build: | |
name: Build the base artifact | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/[email protected] | |
- name: Setup node env π | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
registry-url: 'https://registry.npmjs.org' | |
scope: '@prestashopcorp' | |
- name: Bump version | |
run: | | |
VERSION=$(echo "${{ github.event.release.tag_name }}" | sed 's/^v//' | cut -d'-' -f1) \ | |
make version | |
# - name: Install composer dependencies | |
# run: composer install --no-dev -o | |
- name: Scoped dependencies | |
run: | | |
COMPOSER_OPTIONS="--no-dev -o" 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/[email protected] | |
- name: Create & upload artifact | |
uses: actions/upload-artifact@v1 | |
with: | |
name: ${{ github.event.repository.name }} | |
path: ../ | |
upload_release_asset_production: | |
name: Upload the production zip asset to the release | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- name: Download artifact | |
uses: actions/download-artifact@v1 | |
with: | |
name: ${{ github.event.repository.name }} | |
- 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" > ps_accounts/ps_accounts/config/config.yml | |
env: | |
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.G_CREDENTIAL_PRODUCTION }} | |
- name: Prepare the production zip | |
run: | | |
cd ${{ github.event.repository.name }} | |
bash bundle-module ${{ github.event.repository.name }}.zip | |
# zip -r ${{ github.event.repository.name }}.zip ${{ github.event.repository.name }} -x '*.git*' '*config/config.yml.*' | |
env: | |
ENV_FILE: ${{ secrets.PS_ACCOUNTS_ENV_PROD }} | |
- name: Publish the production zip | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ./${{ github.event.repository.name }}/dist/${{ github.event.repository.name }}.zip | |
asset_name: ${{ github.event.repository.name }}.zip | |
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: Download artifact | |
uses: actions/download-artifact@v1 | |
with: | |
name: ${{ github.event.repository.name }} | |
- 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" > ps_accounts/ps_accounts/config/config.yml | |
env: | |
GOOGLE_APPLICATION_CREDENTIALS: ${{ secrets.G_CREDENTIAL_PREPROD }} | |
- name: Prepare the preprod zip | |
run: | | |
cd ${{ github.event.repository.name }} | |
bash bundle-module ${{ github.event.repository.name }}_preprod.zip | |
# zip -r ${{ github.event.repository.name }}_preprod.zip ${{ github.event.repository.name }} -x '*.git*' '*config/config.yml.*' | |
- name: Publish the preprod zip | |
uses: actions/[email protected] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ github.event.release.upload_url }} | |
asset_path: ./${{ github.event.repository.name }}/dist/${{ github.event.repository.name }}_preprod.zip | |
asset_name: ${{ github.event.repository.name }}_preprod.zip | |
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/[email protected] | |
- name: Download release asset | |
uses: dsaltares/[email protected] | |
with: | |
repo: ${{ github.event.repository.full_name }} | |
version: ${{ github.event.release.id }} | |
file: ${{ github.event.repository.name }}.zip | |
token: ${{ secrets.JARVIS_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/${{ github.event.repository.name }}.zip --metadata-json=$PWD/.github/mktp-metadata.json --changelog="${{ github.event.release.body }}" --debug | |
env: | |
MARKETPLACE_API_KEY: ${{ secrets.MARKETPLACE_API_KEY }} |