CI: Add new workflow to create all casks [skip-ci]

Now we can create the casks of some specific release ('latest' in this
case) at will, based purely on the artifact files and on nothing in the
repo. We do not even need to fetch the repo.

This is still some kind of WIP, because we do not have the secrets and
not even a proper homebrew fork in our organization.

THIS WILL NOT WORK out of the box. Refer to PR #1008 to get instruction
on additional steps needed to make this run.

[note]
Remove cask generation from normal release workflow.
Later on the release workflow has to trigger the cask workflow.

Signed-off-by: Fini Jastrow <ulf.fini.jastrow@desy.de>
This commit is contained in:
Fini Jastrow 2022-11-30 00:00:18 +01:00 committed by Fini
parent 1cbe7a1813
commit 762be5b638
3 changed files with 92 additions and 20 deletions

89
.github/workflows/casks.yml vendored Normal file
View file

@ -0,0 +1,89 @@
name: Create Casks PR
env:
HOMEBREW_REPO: Homebrew/homebrew-cask-fonts
HOMEBREW_FORK: Finii/homebrew-cask-fonts
FORK_USER: Finii
FORK_TOKEN: tvguho_cng_11NQ2SVID0Fs35qI0dkGL2_r0WStECYXKRoaOg8ZkkhjtKKJrzRYEzXkGBolrn2NqJFGFCT5COv8lyixqy
on:
workflow_dispatch:
jobs:
create-casks:
name: Create casks
runs-on: ubuntu-latest
steps:
- name: Fetch stuff (no checkout)
uses: Bhacaz/checkout-files@v2
with:
files: bin/scripts/lib/fonts.json bin/scripts/fetch-archives.sh bin/scripts/generate-casks.sh
branch: ${{ github.head_ref || github.ref_name }}
- name: Fetch release artifacts
run: |
cd bin/scripts
chmod u+x *
./fetch-archives.sh latest Heavy
- name: Determine release tag
id: releasetag
run: |
TAG=$(ls archives/_Release* | head -n 1 | sed 's/.*_Release_//')
echo "Release has tag ${TAG}"
echo "tag=${TAG}" >> $GITHUB_OUTPUT
- name: Create all casks
run: |
cd bin/scripts
./generate-casks.sh --setversion ${{ steps.releasetag.outputs.tag }}
- name: Upload casks as artifacts
uses: actions/upload-artifact@v2
with:
name: casks
path: casks
outputs:
tag: ${{ steps.releasetag.outputs.tag }}
commit-casks:
name: Create commits
runs-on: ubuntu-latest
needs: create-casks
steps:
- name: Do some preparation
id: notsecret
run: |
PAK=$(echo "${FORK_TOKEN}" | tr 'A-Za-z' 'N-ZA-Mn-za-m')
echo "pak=${PAK}" >> $GITHUB_OUTPUT
- name: Checkout Homebrew
uses: actions/checkout@v3
with:
repository: ${{ env.HOMEBREW_FORK }}
path: homebrew
ref: nerdfonts
token: ${{ steps.notsecret.outputs.pak }}
- name: Update Homebrew fork
run: |
cd homebrew
git remote add upstream https://github.com/${{ env.HOMEBREW_REPO }}.git
git fetch upstream master
git reset --hard upstream/master
git push --force origin HEAD:nerdfonts
- name: Retrieve new casks
uses: actions/download-artifact@v2
with:
name: casks
path: casks
- name: Prepare changes
run: |
cp casks/* homebrew/Casks
- name: Commit changes
uses: EndBug/add-and-commit@v9
with:
cwd: homebrew
fetch: false
add: Casks
message: "[ci] Update Nerd Font casks to ${{ needs.create-casks.outputs.tag }}"
committer_name: GitHub Actions
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
- name: Create PR
run: |
echo "Well, this would automatically create a PR, but this is disabled for now:"
echo gh pr create -p ${{ env.HOMEBREW_REPO }} -B master -H nerdfonts -R ${{ env.HOMEBREW_FORK }} -d -f

View file

@ -196,14 +196,6 @@ jobs:
cd -- "$GITHUB_WORKSPACE/bin/scripts"
./archive-fonts.sh "${{ matrix.font }}"
- name: Generate casks
id: cask_generate
run: |
cd -- "$GITHUB_WORKSPACE/bin/scripts"
gen=$(./generate-casks.sh "${{ matrix.font }}")
echo $gen
echo path=$(echo "$gen" | grep '^## Created' | sed -E 's/.*: +//') >> $GITHUB_OUTPUT
- name: Upload zip file archive for release
uses: softprops/action-gh-release@v0.1.14
if: needs.setup-fonts-matrix.outputs.rel_upload == 'true'
@ -223,16 +215,6 @@ jobs:
patched-fonts/${{ matrix.font }}
LICENSE
- name: Upload casks as artifacts
uses: actions/upload-artifact@v2
with:
name: casks
# adding multiple paths (i.e. LICENSE) is a workaround to get a least common ancestor
# of the root directory for artifact path purposes
path: |
${{ steps.cask_generate.outputs.path }}
LICENSE
release-font-patcher:
name: Archive font patcher and add to release
needs: [ setup-fonts-matrix, build ]

View file

@ -7,9 +7,9 @@ Note: Usually you need to call the scripts in this directory while actually bein
* `data/`: Contains plain text files used to generate the CSS and cheat sheet files
* `data/sankey/`: Contains instructions on how to create the sankey glyph table manually [3]
* `docker-entrypoint.sh`: This script is packaged into the docker container and is usually used to start patching [2]
* `fetch-archives.sh`: Script to download the release zip archives [4]
* `fetch-archives.sh`: Script to download the release zip archives [6]
* `fpfix.py`: Can be used to set isFixedPitch property in a font [x]
* `generate-casks.sh`: Generates cask files for fonts from data in `archives/` [3]
* `generate-casks.sh`: Generates cask files for fonts from data in `archives/` [6]
* `generate-css.sh`: Generates the Nerd Fonts CCS, which can be used to access the glyphs on a web page [1]
* `generate-fontconfig.sh`: Generates font configuration to enable use of unpatched fonts with Symbols Only Nerd Font [1]
* `generate-font-image-previews.sh`: Generates the preview images for `nerdfonts.com` (i.e. gh-pages) [3]
@ -34,4 +34,5 @@ Note: Usually you need to call the scripts in this directory while actually bein
[3] To be used manually (sigh)
[4] To be used manually
[5] Used by CI (github packsvgs workflow)
[6] Used by CI (github casks workflow)
[x] Probably not used by anything