-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from clFaster/feature/github-workflow
feat: add workflow to build extension artifact
- Loading branch information
Showing
4 changed files
with
171 additions
and
3 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
name: "Build TapToQR Artifact" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
VERSION: | ||
description: "The version of the addon to build" | ||
type: string | ||
required: false | ||
|
||
workflow_call: | ||
inputs: | ||
VERSION: | ||
description: "The version of the addon to build" | ||
type: string | ||
required: false | ||
push: | ||
branches: | ||
- main | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && 'pull_request' || 'push' }}-${{ github.event.pull_request.number || github.ref_name }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
build-artifact: | ||
name: "Build TapToQR Artifact" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '22' | ||
cache: 'npm' | ||
|
||
- name: Determine VERSION | ||
id: determine-version | ||
run: | | ||
if [ -z "${{ inputs.VERSION }}" ]; then | ||
echo "Using repository version" | ||
echo ${{ vars.VERSION }} | ||
echo "VERSION=${{ vars.VERSION }}" >> $GITHUB_OUTPUT | ||
else | ||
echo "Using input version" | ||
echo ${{ inputs.VERSION }} | ||
echo "VERSION=${{ inputs.VERSION }}" >> $GITHUB_OUTPUT | ||
fi | ||
- name: Update Version | ||
run: | | ||
jq --arg version "${{steps.determine-version.outputs.VERSION}}" '.version = $version' package.json > temp.json && mv temp.json package.json | ||
cd addon | ||
jq --arg version "${{steps.determine-version.outputs.VERSION}}" '.version = $version' manifest.json > temp.json && mv temp.json manifest.json | ||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: Lint code | ||
run: npm run lint | ||
|
||
- name: Webpack project | ||
run: npm run webpack-prod | ||
|
||
- name: Create Artifact | ||
run: | | ||
cd addon | ||
zip -r ../TapToQR-${{steps.determine-version.outputs.VERSION}}.zip ./* | ||
- name: Upload artifact | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
path: 'TapToQR-${{steps.determine-version.outputs.VERSION}}.zip' | ||
name: 'TapToQR-addon' |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
name: "Release TapToQR" | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release-type: | ||
type: choice | ||
description: Which type of release to create? | ||
required: true | ||
default: patch | ||
options: | ||
- patch | ||
- minor | ||
- major | ||
|
||
concurrency: | ||
group: ${{ github.workflow }} | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
# Get the Current Version and Bump it depending on the release-type input | ||
update-version: | ||
runs-on: ubuntu-latest | ||
permissions: write-all | ||
outputs: | ||
new_version: ${{ steps.bump_version.outputs.new_version }} | ||
steps: | ||
- name: Ensure branch is main | ||
if: github.ref != 'refs/heads/main' | ||
run: | | ||
text="Publish a new version can only be done from the main branch." | ||
echo "::error title=Wrong Branch::$text" | ||
exit 1 | ||
- name: Read current version | ||
run: | | ||
echo "Current version: ${{ vars.VERSION }}" | ||
- name: Bump version | ||
id: bump_version | ||
run: | | ||
# Retrieve the increment type from the GitHub Actions input | ||
increment="${{ inputs.release-type }}" | ||
# Split the VERSION variable into its major, minor, and patch components | ||
IFS='.' read -r -a parts <<< "${{ vars.VERSION }}" | ||
# Check if the VERSION variable was split correctly | ||
if [ "${#parts[@]}" -ne 3 ]; then | ||
echo "Invalid version format" | ||
exit 1 | ||
fi | ||
major=${parts[0]} | ||
minor=${parts[1]} | ||
patch=${parts[2]} | ||
# Increment the appropriate version component | ||
if [ "$increment" = "major" ]; then | ||
major=$((major + 1)) | ||
minor=0 | ||
patch=0 | ||
elif [ "$increment" = "minor" ]; then | ||
minor=$((minor + 1)) | ||
patch=0 | ||
elif [ "$increment" = "patch" ]; then | ||
patch=$((patch + 1)) | ||
else | ||
echo "Invalid increment type" | ||
exit 1 | ||
fi | ||
# Construct the new version string | ||
new_version="$major.$minor.$patch" | ||
# Output the new version | ||
echo "New version: $new_version" | ||
# Set the output variable for GitHub Actions | ||
echo "new_version=$new_version" >> $GITHUB_OUTPUT | ||
- name: Update version var | ||
id: write_version | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
gh variable set VERSION --body "${{ steps.bump_version.outputs.new_version }}" |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,11 +22,11 @@ | |
"matches": ["<all_urls>"] | ||
} | ||
], | ||
|
||
"content_security_policy": { | ||
"extension_pages": "script-src 'self'; object-src 'self';" | ||
}, | ||
|
||
"action": { | ||
"default_popup": "popup/tap-to-qr.html", | ||
"default_area": "navbar" | ||
|
@@ -40,5 +40,4 @@ | |
"id": "[email protected]" | ||
} | ||
} | ||
|
||
} |
This file contains 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