forked from Quicksaver/Tab-Groups
-
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.
- Loading branch information
Showing
1 changed file
with
83 additions
and
0 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,83 @@ | ||
name: dev-build | ||
|
||
on: | ||
push: | ||
branches: [ master ] | ||
|
||
env: | ||
XPI_NAME: Tab-Groups-2.1.4b1_r | ||
CHANGELOG_EXIST: false | ||
PREVIOUS_TAG: '' | ||
NOTES: 'This release includes an XPI file that is automatically generated after each push to the main branch.' | ||
|
||
jobs: | ||
build-and-upload: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repo | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
ref: main | ||
|
||
- name: Set version in install.rdf | ||
run: | | ||
previous_tag=$(git tag --sort=-creatordate | head -n 1) | ||
echo "PREVIOUS_TAG=$previous_tag" >> $GITHUB_ENV | ||
changelog_exist=$( [[ $(git rev-parse $previous_tag) != $(git rev-parse HEAD) ]] && echo true || echo false ) | ||
echo "CHANGELOG_EXIST=$changelog_exist" >> $GITHUB_ENV | ||
date=$(date +'%Y%m%d.%H%M') | ||
sed -i "s/2.1.4b1_r2.0/2.1.4b1_r$date/" addon/install.rdf | ||
echo "next version: $version-$date" | ||
- name: Zip addon folder | ||
run: | | ||
del pack.ps1 | ||
zip -rq /tmp/${{ env.XPI_NAME }}.xpi * | ||
- name: Update dev-build tag | ||
run: | | ||
if [ $(git rev-parse dev-build) != $(git rev-parse HEAD) ]; then | ||
git tag -d dev-build && git tag dev-build $(git rev-parse HEAD) | ||
fi | ||
- name: Create CHANGELOG | ||
if: ${{ env.CHANGELOG_EXIST }} | ||
uses: requarks/[email protected] | ||
with: | ||
token: ${{ github.token }} | ||
fromTag: 'dev-build' | ||
toTag: ${{ env.PREVIOUS_TAG }} | ||
excludeTypes: '' | ||
|
||
- name: Modify CHANGELOG | ||
if: ${{ env.CHANGELOG_EXIST }} | ||
run: | | ||
node -e ' | ||
let content = fs.readFileSync("CHANGELOG.md", "utf8"); | ||
let newContent = content.replace("### :wrench: Chores", "### :wrench: Maintenance").split("\n").slice(5); | ||
newContent.unshift("${{ env.NOTES }}"); | ||
newContent = newContent.map(line => { | ||
return line | ||
.replace(" *(commit by [@117649](https://github.com/117649))*", "") | ||
.replace(/-\s*(\[.{9}\][^)]*\))\s-\s(.*)/g, "- $2 ($1)") | ||
.replace(/__/g, "\\_\\_") | ||
.replace(/followup/gi, "follow up") | ||
.replace(/(-\s*)(\w)/g, (_, p1, p2) => p1 + p2.toUpperCase()) | ||
.replace(/(Bug|bug)\s(\d{5,7})/g, "[$&](https://bugzilla.mozilla.org/show_bug.cgi?id=$2)"); | ||
}); | ||
fs.writeFileSync("CHANGELOG.md", newContent.join("\n")); | ||
' | ||
- name: Upload release asset to GitHub | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
if [ ${{ env.CHANGELOG_EXIST }} ]; then | ||
gh release edit dev-build --draft=false --notes-file=CHANGELOG.md | ||
else | ||
url=https://github.com/117649/Tab-Groups/releases/tag/${{ env.PREVIOUS_TAG }} | ||
notes="${{ env.NOTES }}<br /><br />No changes since [${{ env.PREVIOUS_TAG }}]($url)" | ||
gh release edit dev-build --draft=false --notes="$notes" | ||
fi | ||
gh release upload dev-build /tmp/${{ env.XPI_NAME }}.xpi --clobber |