okaryo.log

Automating Chrome Extension Uploads to the Store Using GitHub Actions | okaryo.log

Automating Chrome Extension Uploads to the Store Using GitHub Actions

    #ChromeExtension#CI/CD#GitHubActions#GitHub

Introduction

I’ve been developing a tab management Chrome extension called TabTabTab as a personal project.

Until now, each release involved building the package locally, zipping it, and manually uploading it to the store. This process became quite cumbersome, so I decided to automate it using GitHub Actions.

How to Set It Up

First, I looked into the Chrome extension documentation and found that there’s an API for publishing items.

Although it’s possible to use curl to call this API, it seemed like a hassle. I searched for a tool and found the following Action:

It seemed like the Action I needed for the task, so I quickly set up the following workflow.

name: Upload to Chrome Web Store

on:
  push:
    tags:
      - '*'

jobs:
  upload:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      - name: Setup node
        uses: actions/setup-node@v4
      - name: Install npm packages
        run: npm ci
      - name: Build
        run: npm run build
      - name: Zip
        run: zip -r dist.zip dist
      - name: Upload to Chrome Web Store
        uses: mnao305/chrome-extension-upload@v5.0.0
        with:
          file-path: dist.zip
          extension-id: ${{ secrets.EXTENSION_ID }}
          client-id: ${{ secrets.CLIENT_ID }}
          client-secret: ${{ secrets.CLIENT_SECRET }}
          refresh-token: ${{ secrets.REFRESH_TOKEN }}
          publish: false

The workflow is triggered by pushing tags. In my case, the build artifacts are in the dist directory, so I zip this directory and upload it.

A point to note about the mnao305/chrome-extension-upload Action for uploading to the store is that by default, it submits the item for review after uploading. If you want to change the store listing text or images before submitting for review, you need to specify publish: false. However, you’ll need to manually submit for review in that case.

For details on how to obtain the client-id, client-secret, and refresh-token, refer to the following documentation.

Conclusion

Now, all that’s left to do during a release is to submit for review.

GitHub Actions has been a real lifesaver, with most of these useful tools available as actions.


Related Posts
Related Posts
Promotion

This site uses Google Analytics.