Merge pull request #136 from simple-login/feature/auto-upload-extension-on-release
Add GitHub workflows
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"template": "${{CHANGELOG}}",
|
||||
"pr_template": "- ${{TITLE}} #${{NUMBER}}",
|
||||
"empty_template": "- no changes",
|
||||
"categories": [
|
||||
{
|
||||
"title": "## 🚀 Features",
|
||||
"labels": ["feature"]
|
||||
},
|
||||
{
|
||||
"title": "## 🐛 Fixes",
|
||||
"labels": ["fix", "bug"]
|
||||
},
|
||||
{
|
||||
"title": "## 🔧 Enhancements",
|
||||
"labels": ["enhancement"]
|
||||
}
|
||||
],
|
||||
"ignore_labels": ["ignore"],
|
||||
"tag_resolver": {
|
||||
"method": "sort"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
name: Lint
|
||||
on:
|
||||
push:
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Install NodeJS
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 14
|
||||
|
||||
- name: Perform linting
|
||||
run: |
|
||||
npm install
|
||||
npm run prettier:check
|
||||
@@ -0,0 +1,160 @@
|
||||
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: 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 "SLACK_CHANGELOG=${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
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
fetch-depth: 1
|
||||
|
||||
- name: Install NodeJS
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 14
|
||||
|
||||
- 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"
|
||||
|
||||
# Set the slack-changelog
|
||||
slack_changelog=$(cat artifacts/slack-changelog)
|
||||
echo "SLACK_CHANGELOG=$slack_changelog" >> $GITHUB_ENV
|
||||
echo "slack changelog: $SLACK_CHANGELOG"
|
||||
|
||||
- name: Build extension
|
||||
run: |
|
||||
npm install
|
||||
npm run build && npm run build-zip
|
||||
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/upload-release-asset@v1.0.1
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
with:
|
||||
upload_url: ${{ env.RELEASE_UPLOAD_URL }}
|
||||
asset_path: ${{ env.ASSET }}
|
||||
asset_name: ${{ env.ASSET }}
|
||||
asset_content_type: application/octet-stream
|
||||
|
||||
- name: Post notification to Slack
|
||||
uses: slackapi/slack-github-action@v1.19.0
|
||||
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 }}
|
||||
@@ -8,6 +8,7 @@
|
||||
"scripts": {
|
||||
"prettier": "prettier \"src/**/*.{js,vue}\"",
|
||||
"prettier:write": "npm run prettier -- --write",
|
||||
"prettier:check": "prettier --check \"src/**/*.{js,vue}\"",
|
||||
"build": "cross-env NODE_ENV=production webpack --hide-modules",
|
||||
"build:beta": "cross-env NODE_ENV=production BETA=1 webpack --hide-modules",
|
||||
"build:dev": "cross-env NODE_ENV=development BETA=1 webpack --hide-modules",
|
||||
|
||||
Reference in New Issue
Block a user