Skip to content

Commit

Permalink
Merge branch 'main' into badges-on-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
Astisme authored Dec 18, 2024
2 parents 966cc52 + f1a2337 commit a60f5a0
Show file tree
Hide file tree
Showing 7 changed files with 356 additions and 245 deletions.
197 changes: 197 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
name: Build Extension and add to Branch

on:
workflow_call:
inputs:
target_branch:
description: "The branch to push the changes to"
required: true
type: string

permissions:
contents: write

jobs:
setup:
runs-on: ubuntu-latest
outputs:
DIRECTORY: ${{ steps.make_dir.outputs.DIST }}
VERSION: ${{ steps.get_version.outputs.VERSION }}
CHROME_VERSION: ${{ steps.def_file_name.outputs.CHROME_VERSION }}
FIREFOX_VERSION: ${{ steps.def_file_name.outputs.FIREFOX_VERSION }}
SAFARI_VERSION: ${{ steps.def_file_name.outputs.SAFARI_VERSION }}
BRANCH_NAME: ${{ steps.push_dir.outputs.BRANCH_NAME }}
steps:
- name: Define prefix
run: echo "AWSF=awsf" >> $GITHUB_ENV

- name: Define file names no version
run: |
echo "CHROME=${{ env.AWSF }}-chrome" >> $GITHUB_ENV
echo "FIREFOX=${{ env.AWSF }}-firefox" >> $GITHUB_ENV
echo "SAFARI=${{ env.AWSF }}-safari" >> $GITHUB_ENV
- name: Setup repo
uses: actions/checkout@v4

- name: Extract current version
id: get_version
run: |
VERSION=$(grep -oP '"version":\s*"\K[0-9.]+' manifest/template-manifest.json)
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
- name: Create versioned directory
id: make_dir
run: |
DIST=dist/v${{ env.VERSION }}
mkdir -p $DIST
touch $DIST/.gitkeep
echo "DIST=$DIST" >> $GITHUB_OUTPUT
- name: Push versioned directory
id: push_dir
run: |
git config user.name "github-actions"
git config user.email = "[email protected]"
# BRANCH_NAME="new-version-${{ env.VERSION }}"
BRANCH_NAME=${{ inputs.target_branch }}
git branch $BRANCH_NAME
git switch $BRANCH_NAME
git add dist
git commit -m "Created new directory"
git push --set-upstream origin $BRANCH_NAME
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_OUTPUT
- name: Define file names with version
id: def_file_name
run: |
echo "CHROME_VERSION=${{ env.CHROME }}-v${{ env.VERSION }}" >> $GITHUB_OUTPUT
echo "FIREFOX_VERSION=${{ env.FIREFOX }}-v${{ env.VERSION }}" >> $GITHUB_OUTPUT
echo "SAFARI_VERSION=${{ env.SAFARI }}-v${{ env.VERSION }}" >> $GITHUB_OUTPUT
chrome:
runs-on: ubuntu-latest
needs: setup
env:
DIRECTORY: ${{ needs.setup.outputs.DIRECTORY }}
VERSION: ${{ needs.setup.outputs.VERSION }}
CHROME_VERSION: ${{ needs.setup.outputs.CHROME_VERSION }}
BRANCH_NAME: ${{ needs.setup.outputs.BRANCH_NAME }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Switch to version branch
run: |
git fetch origin "$BRANCH_NAME"
git switch $BRANCH_NAME
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Make Chrome Manifest
run: deno run dev-chrome

- name: Zip Chrome extension
run: zip -r $DIRECTORY/$CHROME_VERSION.zip action assets background salesforce *.js LICENSE.txt README.md manifest.json -x "*/README.md"

- name: Upload Chrome artifact
uses: actions/upload-artifact@v3
with:
name: $CHROME_VERSION
path: $DIRECTORY/$CHROME_VERSION.zip

- name: Push Chrome artifact
run: |
git config user.name "github-actions"
git config user.email = "[email protected]"
git add dist
git commit -m "Chrome v$VERSION"
git push
firefox:
runs-on: ubuntu-latest
needs: [setup, chrome]
env:
DIRECTORY: ${{ needs.setup.outputs.DIRECTORY }}
VERSION: ${{ needs.setup.outputs.VERSION }}
FIREFOX_VERSION: ${{ needs.setup.outputs.FIREFOX_VERSION }}
BRANCH_NAME: ${{ needs.setup.outputs.BRANCH_NAME }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Switch to version branch
run: |
git fetch origin "$BRANCH_NAME"
git switch $BRANCH_NAME
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Make Firefox Manifest
run: deno run dev-firefox

- name: Zip Firefox extension
run: zip -r $DIRECTORY/$FIREFOX_VERSION.zip action assets background salesforce *.js LICENSE.txt README.md manifest.json -x "*/README.md"

- name: Upload Firefox artifact
uses: actions/upload-artifact@v3
with:
name: $FIREFOX_VERSION
path: $DIRECTORY/$FIREFOX_VERSION.zip

- name: Push Firefox artifact
run: |
git config user.name "github-actions"
git config user.email = "[email protected]"
git add dist
git commit -m "Firefox v$VERSION"
git push
safari:
runs-on: ubuntu-latest
needs: [setup, firefox]
env:
DIRECTORY: ${{ needs.setup.outputs.DIRECTORY }}
VERSION: ${{ needs.setup.outputs.VERSION }}
SAFARI_VERSION: ${{ needs.setup.outputs.SAFARI_VERSION }}
BRANCH_NAME: ${{ needs.setup.outputs.BRANCH_NAME }}
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Switch to version branch
run: |
git fetch origin "$BRANCH_NAME"
git switch $BRANCH_NAME
- name: Setup Deno
uses: denoland/setup-deno@v2
with:
deno-version: v2.x

- name: Make Safari Manifest
run: deno run dev-safari

- name: Zip Safari extension
run: zip -r $DIRECTORY/$SAFARI_VERSION.zip action assets background salesforce *.js LICENSE.txt README.md manifest.json -x "*/README.md"

- name: Upload Safari artifact
uses: actions/upload-artifact@v3
with:
name: $SAFARI_VERSION
path: $DIRECTORY/$SAFARI_VERSION.zip

- name: Push Safari artifact
run: |
git config user.name "github-actions"
git config user.email = "[email protected]"
git add dist
git commit -m "Safari v$VERSION"
git push
Loading

0 comments on commit a60f5a0

Please sign in to comment.