docs: update extension ID and add logo to README #9
This file contains hidden or 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: Create Release | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| # Add global permissions for the workflow | |
| permissions: | |
| contents: write # This is necessary to create releases and tags | |
| issues: read | |
| pull-requests: read | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| # We can also specify permissions at the job level if needed | |
| # permissions: | |
| # contents: write | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 # Necessary to get all commits for the changelog | |
| - name: Get version from manifest | |
| id: get_version | |
| run: | | |
| VERSION=$(grep '"version"' manifest.json | cut -d '"' -f 4) | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| echo "Found version: $VERSION" | |
| - name: Check if tag exists | |
| id: check_tag | |
| run: | | |
| git fetch --tags | |
| if git rev-parse "v$VERSION" >/dev/null 2>&1; then | |
| echo "TAG_EXISTS=true" >> $GITHUB_ENV | |
| echo "Tag v$VERSION already exists" | |
| else | |
| echo "TAG_EXISTS=false" >> $GITHUB_ENV | |
| echo "Tag v$VERSION does not exist yet" | |
| fi | |
| - name: Setup Node.js | |
| if: env.TAG_EXISTS != 'true' | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: '18' | |
| - name: Cache Node modules | |
| if: env.TAG_EXISTS != 'true' | |
| uses: actions/cache@v3 | |
| with: | |
| path: node_modules | |
| key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-node- | |
| - name: Validate required files | |
| if: env.TAG_EXISTS != 'true' | |
| id: validate | |
| run: | | |
| MISSING_FILES=0 | |
| # List of required files | |
| REQUIRED_FILES=( | |
| "manifest.json" | |
| "content.js" | |
| "background.js" | |
| ) | |
| # Check each required file | |
| for file in "${REQUIRED_FILES[@]}"; do | |
| if [ ! -f "$file" ]; then | |
| echo "Error: Required file '$file' is missing" | |
| MISSING_FILES=$((MISSING_FILES+1)) | |
| else | |
| echo "✓ Found required file: $file" | |
| fi | |
| done | |
| # Check images directory | |
| if [ ! -d "img" ]; then | |
| echo "Error: Required directory 'img' is missing" | |
| MISSING_FILES=$((MISSING_FILES+1)) | |
| else | |
| echo "✓ Found img directory" | |
| # Check icons | |
| for icon in "icon16.png" "icon48.png" "icon128.png"; do | |
| if [ ! -f "img/$icon" ]; then | |
| echo "Warning: Icon 'img/$icon' is missing" | |
| else | |
| echo "✓ Found icon: img/$icon" | |
| fi | |
| done | |
| fi | |
| # Exit if critical files are missing | |
| if [ $MISSING_FILES -gt 0 ]; then | |
| echo "Error: $MISSING_FILES required files are missing. Cannot create release." | |
| exit 1 | |
| fi | |
| echo "All required files are present!" | |
| - name: Generate changelog | |
| if: env.TAG_EXISTS != 'true' | |
| id: changelog | |
| run: | | |
| echo "## Changes since last release" > changelog.md | |
| # Get the last tag (if it exists) | |
| LAST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "") | |
| if [ -z "$LAST_TAG" ]; then | |
| # If there are no previous tags, show all commits | |
| echo "### First release - All changes" >> changelog.md | |
| git log --pretty=format:"* %s (%h)" >> changelog.md | |
| else | |
| # If there's a previous tag, show changes since that tag | |
| echo "### Changes since $LAST_TAG" >> changelog.md | |
| git log $LAST_TAG..HEAD --pretty=format:"* %s (%h)" >> changelog.md | |
| fi | |
| echo "" >> changelog.md | |
| echo "Automatically generated on $(date '+%Y-%m-%d %H:%M:%S')" >> changelog.md | |
| # Show changelog for debugging | |
| echo "Generated changelog:" | |
| cat changelog.md | |
| - name: Package Extension | |
| if: env.TAG_EXISTS != 'true' | |
| run: | | |
| # Package the extension | |
| echo "Packaging extension v$VERSION" | |
| # Define output zip file | |
| ZIP_FILE="bigcommerce-wysiwyg-editor-v$VERSION.zip" | |
| # Create package directory | |
| mkdir -p temp_package/img | |
| # Copy files to package directory - Copy all main files | |
| cp manifest.json temp_package/ | |
| cp content.js temp_package/ | |
| cp background.js temp_package/ | |
| # Copy optional files | |
| cp popup.js temp_package/ 2>/dev/null || echo "popup.js not found, skipping" | |
| cp popup.html temp_package/ 2>/dev/null || echo "popup.html not found, skipping" | |
| cp README.md temp_package/ 2>/dev/null || echo "README.md not found, skipping" | |
| cp PRIVACY_POLICY.md temp_package/ 2>/dev/null || echo "PRIVACY_POLICY.md not found, skipping" | |
| # Copy icons | |
| cp img/icon16.png temp_package/img/ 2>/dev/null || echo "icon16.png not found, skipping" | |
| cp img/icon48.png temp_package/img/ 2>/dev/null || echo "icon48.png not found, skipping" | |
| cp img/icon128.png temp_package/img/ 2>/dev/null || echo "icon128.png not found, skipping" | |
| # Create zip file | |
| cd temp_package | |
| zip -r ../$ZIP_FILE * | |
| cd .. | |
| # Show ZIP contents | |
| echo "ZIP contains:" | |
| unzip -l $ZIP_FILE | |
| # Clean up | |
| rm -rf temp_package | |
| # Set output | |
| echo "ZIP_FILE=$ZIP_FILE" >> $GITHUB_ENV | |
| echo "Created ZIP file: $ZIP_FILE" | |
| - name: Generate Release Notes | |
| if: env.TAG_EXISTS != 'true' | |
| id: release_notes | |
| run: | | |
| cat > release_notes.md << EOL | |
| # BigCommerce WYSIWYG Editor v$VERSION | |
| This version was automatically generated from the latest code in the master branch. | |
| ## Main Features | |
| - Enhanced WYSIWYG editor for BigCommerce | |
| - Improved text editing capabilities | |
| - Bug fixes and performance improvements | |
| ## Installation | |
| 1. Download the ZIP file | |
| 2. Unzip to a local folder | |
| 3. In Chrome, go to chrome://extensions/ | |
| 4. Enable "Developer mode" | |
| 5. Click "Load unpacked" and select the unzipped folder | |
| 6. The extension should now be installed and active | |
| EOL | |
| # Add the generated changelog | |
| cat changelog.md >> release_notes.md | |
| echo "## Known Issues" >> release_notes.md | |
| echo "" >> release_notes.md | |
| echo "Please report any issues in the GitHub repository." >> release_notes.md | |
| echo "Created release notes file" | |
| # Create the tag first | |
| - name: Create Git Tag | |
| if: env.TAG_EXISTS != 'true' | |
| run: | | |
| git config --local user.email "action@github.com" | |
| git config --local user.name "GitHub Action" | |
| git tag -a "v$VERSION" -m "Release v$VERSION" | |
| git push origin "v$VERSION" | |
| - name: Create Release | |
| if: env.TAG_EXISTS != 'true' | |
| id: create_release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ env.VERSION }} | |
| name: Release v${{ env.VERSION }} | |
| body_path: release_notes.md | |
| draft: false | |
| prerelease: false | |
| files: | | |
| ${{ env.ZIP_FILE }} | |
| - name: Tag Already Exists | |
| if: env.TAG_EXISTS == 'true' | |
| run: | | |
| echo "::warning::Tag v$VERSION already exists in the repository. A new release will not be created." | |
| echo "If you need to update this release, first delete the existing tag with:" | |
| echo "git tag -d v$VERSION" | |
| echo "git push --delete origin v$VERSION" | |
| echo "Then run this workflow again." |