Publish pre-release #469
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
name: Publish pre-release | |
on: | |
schedule: | |
- cron: '0 9 * * *' # every day at 4am EST | |
workflow_dispatch: | |
jobs: | |
check: | |
name: Check for updates | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
outputs: | |
status: ${{ steps.earlyexit.outputs.status }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- id: earlyexit | |
run: | | |
git config user.name github-actions | |
git config user.email [email protected] | |
if git rev-parse origin/pre >/dev/null 2>&1; then | |
preRef=$(git show-ref -s origin/pre) | |
headRef=$(git show-ref --head -s head) | |
echo "origin/pre" | |
echo $preRef | |
echo "HEAD" | |
echo $headRef | |
if [ "$preRef" = "$headRef" ]; then | |
echo "No changes since last pre-release build. Exiting." | |
echo "status=unchanged" >> $GITHUB_OUTPUT | |
exit 0 | |
else | |
echo "Updating pre" | |
git push origin --delete pre | |
git checkout -b pre | |
git push origin pre | |
fi | |
else | |
echo "No pre branch. Creating." | |
git checkout -b pre | |
git push origin pre | |
fi | |
echo "status=changed" >> $GITHUB_OUTPUT | |
publish: | |
name: Publish pre-release | |
needs: check | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
env: | |
FF_API_KEY: ${{ secrets.FF_API_KEY }} | |
FF_API_SECRET: ${{ secrets.FF_API_SECRET }} | |
timeout-minutes: 15 | |
if: needs.check.outputs.status == 'changed' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Install | |
run: yarn | |
- name: Apply pre-release patch | |
run: yarn run patch-pre | |
- name: Setup Environment | |
run: node -e "console.log('PACKAGE_VERSION=' + require('./package.json').version + '\nPACKAGE_NAME=' + require('./package.json').name + '-' + require('./package.json').version + '\nFF_ADDON_NAME=' + 'gitkraken_browser_extension' +'-' + require('./package.json').version)" >> $GITHUB_ENV | |
- name: Package extension | |
run: yarn run package | |
- name: Publish chromium artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.PACKAGE_NAME }}-chromium.zip | |
path: ./${{ env.PACKAGE_NAME }}-chromium.zip | |
- name: Publish firefox artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.FF_ADDON_NAME }}.xpi | |
path: ./${{ env.FF_ADDON_NAME }}.xpi | |
- name: Create GitHub release | |
id: create_release | |
uses: softprops/action-gh-release@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
tag_name: v${{ env.PACKAGE_VERSION }}-pre | |
name: v${{ env.PACKAGE_VERSION }}-pre | |
draft: false | |
prerelease: true | |
files: | | |
./${{ env.PACKAGE_NAME }}-chromium.zip | |
./${{ env.FF_ADDON_NAME }}.xpi |