-
Notifications
You must be signed in to change notification settings - Fork 1
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
92 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,92 @@ | ||
name: dev-build | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
|
||
env: | ||
XPI_NAME: easy_dragtogo_smod-1.1.7.b29-fx_r | ||
CHANGELOG_EXIST: false | ||
PREVIOUS_TAG: '' | ||
NOTES: 'This release includes an XPI file that is automatically generated after each push to the master 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 | grep -E '^1.1.7.b29-fx_r*' | 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/1.1.7.b29_r1.2/1.1.7.b29_r$date/" addon/install.rdf | ||
echo "next version: $version-$date" | ||
echo "XPI_NAME=${{ env.XPI_NAME }}$date" >> $GITHUB_ENV | ||
- name: Zip addon folder | ||
run: | | ||
cd addon | ||
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) | ||
git push origin -f dev-build | ||
fi | ||
- name: Create CHANGELOG | ||
if: ${{ env.CHANGELOG_EXIST }} | ||
uses: requarks/[email protected] | ||
with: | ||
token: ${{ github.token }} | ||
fromTag: 'dev-build' | ||
toTag: ${{ env.PREVIOUS_TAG }} | ||
excludeTypes: '' | ||
includeInvalidCommits: true | ||
|
||
- 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/EasyDragToGoPlus-Redux/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 | ||
ASSETS=$(gh release view dev-build --json assets -q '.assets[].name') | ||
for ASSET_NAME in $ASSETS; do | ||
if [[ $ASSET_NAME == *.xpi ]]; then | ||
gh release delete-asset dev-build $ASSET_NAME --yes | ||
fi | ||
done | ||
gh release upload dev-build /tmp/${{ env.XPI_NAME }}.xpi --clobber |