Skip to content

Publish extensions πŸš€ #17

Publish extensions πŸš€

Publish extensions πŸš€ #17

Workflow file for this run

name: 'Publish extensions πŸš€'
on:
workflow_dispatch:
inputs:
environment:
description: 'The environment to publish the extensions to'
required: true
type: choice
options:
- 'testing'
- 'production'
concurrency:
group: '${{ github.workflow }}-${{ github.ref }}'
cancel-in-progress: true
jobs:
prepare:
runs-on: ubuntu-22.04
outputs:
version: ${{ steps.prerelease.outputs.version || steps.testing.outputs.version }}
released: ${{ steps.prerelease.outputs.released || steps.testing.outputs.released }}
steps:
- uses: myparcelnl/actions/setup-git-credentials@v4
if: inputs.environment == 'production'
id: credentials
with:
app-id: ${{ secrets.MYPARCEL_APP_ID }}
private-key: ${{ secrets.MYPARCEL_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
if: inputs.environment == 'production'
with:
fetch-depth: 0
fetch-tags: true
token: ${{ steps.credentials.outputs.token }}
- uses: myparcelnl/actions/yarn-install@v4
if: inputs.environment == 'production'
with:
node-version: ${{ vars.NODE_VERSION }}
- uses: myparcelnl/actions/semantic-release@v4
name: 'Determine new version'
if: inputs.environment == 'production'
id: prerelease
with:
token: ${{ steps.credentials.outputs.token }}
dry-run: true
- id: testing
if: inputs.environment != 'production'
shell: bash
#language=bash
run: |
echo "version=(testing)" >> $GITHUB_OUTPUT
echo "released=false" >> $GITHUB_OUTPUT
deploy:
name: 'Publish ${{ inputs.environment }} ${{ needs.prepare.outputs.version }} extensions'
needs:
- prepare
runs-on: ubuntu-22.04
environment:
name: ${{ inputs.environment }}
steps:
- uses: myparcelnl/actions/setup-git-credentials@v4
id: credentials
with:
app-id: ${{ secrets.MYPARCEL_APP_ID }}
private-key: ${{ secrets.MYPARCEL_APP_PRIVATE_KEY }}
- uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ steps.credentials.outputs.token }}
###
# This is also done by semantic-release itself, but we want to know if the build step passes before running
# semantic-release. The new version needs to be in the build, so we need to update it before building.
###
- name: 'Update version in package.json'
if: inputs.environment == 'production' && needs.prepare.outputs.released == 'true'
env:
VERSION: ${{ needs.prepare.outputs.version }}
shell: bash
#language=bash
run: |
npm version --no-git-tag-version "$VERSION"
- uses: ./.github/actions/build
with:
node-version: ${{ vars.NODE_VERSION }}
- uses: myparcelnl/actions/semantic-release@v4
if: inputs.environment == 'production' && needs.prepare.outputs.released == 'true'
id: release
with:
token: ${{ steps.credentials.outputs.token }}
write-summary: true
- name: 'Prepare'
id: prepare
env:
IS_PRODUCTION: ${{ inputs.environment == 'production' }}
shell: bash
# language=bash
run: |
if [ $IS_PRODUCTION == true ]; then
echo "target=default" >> $GITHUB_OUTPUT
echo "zip-path-myparcel=dist/myparcel.zip" >> $GITHUB_OUTPUT
echo "zip-path-flespakket=dist/flespakket.zip" >> $GITHUB_OUTPUT
echo "zip-path-sendmyparcel=dist/sendmyparcel.zip" >> $GITHUB_OUTPUT
else
echo "target=trustedTesters" >> $GITHUB_OUTPUT
echo "zip-path-myparcel=dist/myparcel-testing.zip" >> $GITHUB_OUTPUT
echo "zip-path-flespakket=dist/flespakket-testing.zip" >> $GITHUB_OUTPUT
echo "zip-path-sendmyparcel=dist/sendmyparcel-testing.zip" >> $GITHUB_OUTPUT
fi
- name: 'Publish MyParcel extension'
uses: mnao305/[email protected]
continue-on-error: true
with:
file-path: ${{ steps.prepare.outputs.zip-path-myparcel }}
publish: true
publish-target: ${{ steps.prepare.outputs.target }}
extension-id: ${{ vars.EXTENSION_ID_MYPARCEL }}
client-id: ${{ secrets.CHROME_WEB_STORE_CLIENT_ID }}
client-secret: ${{ secrets.CHROME_WEB_STORE_CLIENT_SECRET }}
refresh-token: ${{ secrets.CHROME_WEB_STORE_REFRESH_TOKEN }}
- name: 'Publish Flespakket testing extension'
uses: mnao305/[email protected]
continue-on-error: true
with:
file-path: ${{ steps.prepare.outputs.zip-path-flespakket }}
publish: true
publish-target: ${{ steps.prepare.outputs.target }}
extension-id: ${{ vars.EXTENSION_ID_FLESPAKKET }}
client-id: ${{ secrets.CHROME_WEB_STORE_CLIENT_ID }}
client-secret: ${{ secrets.CHROME_WEB_STORE_CLIENT_SECRET }}
refresh-token: ${{ secrets.CHROME_WEB_STORE_REFRESH_TOKEN }}
- name: 'Publish SendMyParcel testing extension'
uses: mnao305/[email protected]
continue-on-error: true
with:
file-path: ${{ steps.prepare.outputs.zip-path-sendmyparcel }}
publish: true
publish-target: ${{ steps.prepare.outputs.target }}
extension-id: ${{ vars.EXTENSION_ID_SENDMYPARCEL }}
client-id: ${{ secrets.CHROME_WEB_STORE_CLIENT_ID }}
client-secret: ${{ secrets.CHROME_WEB_STORE_CLIENT_SECRET }}
refresh-token: ${{ secrets.CHROME_WEB_STORE_REFRESH_TOKEN }}