Skip to content

Merge pull request #219 from simple-login/fix/extension-automatic-setup #25

Merge pull request #219 from simple-login/fix/extension-automatic-setup

Merge pull request #219 from simple-login/fix/extension-automatic-setup #25

Workflow file for this run

name: Build the extension
on:
push:
tags:
- '[0-9]+.[0-9]+.[0-9]+'
jobs:
create-release:
name: create-release
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install dependencies and check tag format
run: |
sudo apt update && sudo apt install -y jq
PACKAGE_JSON_VERSION=$(jq -Mr '.version' package.json)
EXTENSION_VERSION=${GITHUB_REF#refs/tags/}
if [[ "${PACKAGE_JSON_VERSION}" != "${EXTENSION_VERSION}" ]]; then
echo "Tag name does not match the version in package.json"
echo "package.json: [${PACKAGE_JSON_VERSION}] | tag: [${EXTENSION_VERSION}]"
exit 1
fi
echo "EXTENSION_VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: Create artifacts directory
run: mkdir artifacts
- name: Build Changelog
id: build_changelog
uses: mikepenz/release-changelog-builder-action@v3
with:
configuration: ".github/changelog_configuration.json"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Prepare Slack notification contents
run: |
changelog=$(cat << EOH
${{ steps.build_changelog.outputs.changelog }}
EOH
)
messageWithoutNewlines=$(echo "${changelog}" | awk '{printf "%s\\n", $0}')
messageWithoutDoubleQuotes=$(echo "${messageWithoutNewlines}" | sed "s/\"/'/g")
echo "${messageWithoutDoubleQuotes}"
echo "${messageWithoutDoubleQuotes}" > artifacts/slack-changelog
- name: Create GitHub release
id: release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ env.EXTENSION_VERSION }}
release_name: ${{ env.EXTENSION_VERSION }}
body: ${{ steps.build_changelog.outputs.changelog }}
- name: Save release upload URL to artifact
run: echo "${{ steps.release.outputs.upload_url }}" > artifacts/release-upload-url
- name: Save version number to artifact
run: echo "${{ env.EXTENSION_VERSION }}" > artifacts/release-version
- name: Upload artifacts
uses: actions/upload-artifact@v1
with:
name: artifacts
path: artifacts
build-release:
name: build-release
needs: ['create-release']
runs-on: ubuntu-latest
strategy:
max-parallel: 4
matrix:
variant: ['full', 'lite', 'mac', 'beta', 'beta-firefox']
steps:
- name: Build info
run: echo "Starting build process for variant = ${{ matrix.variant }}"
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 1
- name: Install NodeJS
uses: actions/setup-node@v3
with:
node-version: 16
- name: Get release download URL
uses: actions/download-artifact@v1
with:
name: artifacts
path: artifacts
- name: Read artifacts
shell: bash
run: |
# Set the release_upload_url
release_upload_url="$(cat artifacts/release-upload-url)"
echo "RELEASE_UPLOAD_URL=$release_upload_url" >> $GITHUB_ENV
echo "release upload url: $RELEASE_UPLOAD_URL"
# Set the release_version
release_version="$(cat artifacts/release-version)"
echo "RELEASE_VERSION=$release_version" >> $GITHUB_ENV
echo "release version: $RELEASE_VERSION"
- name: Generate buildConfig
shell: bash
env:
ENABLE_LOGIN_WITH_PROTON: true
run: |
npm run generate:buildconfig
- name: Build lite version
if: matrix.variant == 'lite'
shell: bash
run: |
npm install
npm run build:lite
SUFFIX=lite npm run build-zip
- name: Build beta version for Chromium
if: matrix.variant == 'beta'
shell: bash
run: |
npm install
npm run build:beta
npm run build-zip
- name: Build beta version for Firefox
if: matrix.variant == 'beta-firefox'
shell: bash
run: |
npm install
npm run build:firefox:beta
# dist-zip/simplelogin-extension-beta-firefox-v... can be submitted to firefox
SUFFIX=firefox npm run build-zip
- name: Build production version for Firefox
if: matrix.variant == 'beta-firefox'
shell: bash
run: |
npm install
npm run build:firefox
# dist-zip/simplelogin-extension-beta-firefox-v... can be submitted to firefox
SUFFIX=firefox npm run build-zip
- name: Build production version for Chromium
if: matrix.variant == 'full'
shell: bash
run: |
npm install
npm run build
npm run build-zip
- name: Build Mac version
if: matrix.variant == 'mac'
shell: bash
run: |
npm install
npm run build:mac
SUFFIX=mac npm run build-zip
- name: Package extension
run: |
ZIP_NAME=$(find dist-zip -type f -name '*.zip' | head -n 1)
ASSET_NAME=$(basename "${ZIP_NAME}")
echo "ASSET_PATH=${ZIP_NAME}" >> $GITHUB_ENV
echo "ASSET_NAME=${ASSET_NAME}" >> $GITHUB_ENV
- name: Upload release archive
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
asset_path: ${{ env.ASSET_PATH }}
asset_name: ${{ env.ASSET_NAME }}
asset_content_type: application/octet-stream
notify:
name: notify
needs: ['create-release', 'build-release']
runs-on: ubuntu-latest
steps:
- name: Get artifacts
uses: actions/download-artifact@v1
with:
name: artifacts
path: artifacts
- name: Read artifacts
shell: bash
run: |
# Set the slack-changelog
slack_changelog=$(cat artifacts/slack-changelog)
echo "SLACK_CHANGELOG=$slack_changelog" >> $GITHUB_ENV
echo "slack changelog: $SLACK_CHANGELOG"
- name: Post notification to Slack
uses: slackapi/[email protected]
with:
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "New tag created on browser-extension",
"emoji": true
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Tag: ${{ github.ref_name }}* (${{ github.sha }})"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Changelog:*\n${{ env.SLACK_CHANGELOG }}"
}
}
]
}
env:
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}