1
0
mirror of https://github.com/ryanoasis/nerd-fonts.git synced 2025-01-06 21:49:40 +02:00

Merge pull request #892 from Finii/improve-ci

Improve CI process for releases
With merge request to have the complete overhaul in a closed context.
This commit is contained in:
Fini 2022-08-26 12:53:28 +02:00 committed by GitHub
commit f90b12ba8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 192 additions and 158 deletions

View File

@ -1,3 +1,4 @@
# Keep this in line with .github/workflows/docker-release.yml
**
!src/glyphs
!font-patcher

View File

@ -5,7 +5,9 @@ on:
branches:
- master
paths:
# Keep this in line with .dockerignore
- bin/scripts/docker-entrypoint.sh
- bin/scripts/name_parser/Fontname*.py
- src/glyphs/**
- .dockerignore
- Dockerfile
@ -15,6 +17,7 @@ jobs:
publish-image:
name: Publish image
runs-on: ubuntu-latest
if: ${{ secrets.DOCKER_USER }}
steps:
- uses: actions/checkout@v3
- name: Build image

View File

@ -16,7 +16,6 @@ on:
- 'install.ps1'
- 'install.sh'
- 'LICENSE'
- 'package**'
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
@ -27,18 +26,72 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
-
# Faster version instead of - uses: actions/checkout@v3
- uses: Bhacaz/checkout-files@v2
with:
files: package.json bin/scripts/get-font-names-from-json.sh bin/scripts/lib/fonts.json
branch: ${{ github.head_ref || github.ref_name }}
- name: Determine font matrix
id: set-matrix
run: |
cd -- $GITHUB_WORKSPACE/bin/scripts/
chmod u+x get-font-names-from-json.sh
fontNames=$(./get-font-names-from-json.sh)
echo "${fontNames}"
echo "::set-output name=matrix::${fontNames}"
echo ${{ steps.set-matrix.outputs.matrix }}
- name: Fetch release version
id: rel_ver
run: |
cd -- "$GITHUB_WORKSPACE"
echo "Contents of package.json:"
cat package.json
RELEASE_VERSION=$(jq '.version' package.json | sed 's/[ ",]//g')
echo "::set-output name=val::$RELEASE_VERSION"
- name: Determine candidate status
id: rel_can
run: |
[[ "${{ steps.rel_ver.outputs.val }}" == *"-RC"* ]] && echo "::set-output name=val::true" || echo "::set-output name=val::false"
- name: Determine new release or re-release
# If the tag exists it is obviously a re-release
# This would need a complete checkout, that we want to avoid
# uses: mukunku/tag-exists-action@v1.0.0
# with:
# tag: "v${{ steps.rel_ver.outputs.val }}"
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: rel_pre_existing
run: |
curl -v "${GITHUB_API_URL}/repos/${GITHUB_REPOSITORY}/tags" | jq '.[].name' | grep '^"v${{ steps.rel_ver.outputs.val }}"$' \
&& echo "::set-output name=exists::true" || echo "::set-output name=exists::false"
echo "Tag exists: ${{ steps.rel_pre_existing.outputs.exists }}"
- name: Upload release only on first trigger for release and always on release candidate
id: upload
# Upload release when:
# * This is a new (previously untagged) release
# * This is a release candidate
run: |
[[ "${{ steps.rel_can.outputs.val }}" == "true" || "${{ steps.rel_pre_existing.outputs.exists }}" == "false" ]] && echo "::set-output name=val::true" || echo "::set-output name=val::false"
- name: Show outputs
run: |
echo "rel_version: ${{ steps.rel_ver.outputs.val }}"
echo "rel_candidate: ${{ steps.rel_can.outputs.val }}"
echo "rel_pre_existing: ${{ steps.rel_pre_existing.outputs.exists }}"
echo "rel_upload: ${{ steps.upload.outputs.val }}"
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
rel_version: ${{ steps.rel_ver.outputs.val }}
rel_candidate: ${{ steps.rel_can.outputs.val }}
rel_pre_existing: ${{ steps.rel_pre_existing.outputs.exists }}
rel_upload: ${{ steps.upload.outputs.val }}
# Workflow to build and install dependencies
build:
@ -50,6 +103,8 @@ jobs:
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ needs.setup-fonts-matrix.outputs.rel_version }}
RELEASE_CANDIDATE: ${{ needs.setup-fonts-matrix.outputs.rel_candidate }}
strategy:
matrix:
@ -58,17 +113,11 @@ jobs:
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v3
- name: Set release variables
- name: Check release variables
run: |
cd -- "$GITHUB_WORKSPACE"
cat package.json
RELEASE_TAG_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo "RELEASE_TAG_VERSION=$RELEASE_TAG_VERSION" >> $GITHUB_ENV
[[ "$RELEASE_TAG_VERSION" == *"-RC"* ]] && echo "RELEASE_CANDIDATE=true" || echo "RELEASE_CANDIDATE=false" >> $GITHUB_ENV
echo "$RELEASE_VERSION"
echo "Candidate: $RELEASE_CANDIDATE"
echo "Publish/refresh release: ${{ needs.setup-fonts-matrix.outputs.rel_upload }}"
# Install and setup Dependencies
# @TODO cache the next 4 steps with actions/cache or upload
@ -92,11 +141,15 @@ jobs:
echo Try appimage with path
fontforge --version
# It is unclear what this has been needed for
- name: Setup additional dependencies
if: false
run: |
pip install fonttools --quiet
# It is unclear what this has been needed for
- name: Build FreeType from source
if: false
run: |
wget http://downloads.sourceforge.net/project/freetype/freetype2/2.7/freetype-2.7.tar.gz --quiet
tar -zxf freetype-2.7.tar.gz
@ -105,7 +158,9 @@ jobs:
make --quiet
sudo make install --quiet
# It is unclear what this has been needed for
- name: Build Harfbuzz from source
if: false
run: |
wget http://www.freedesktop.org/software/harfbuzz/release/harfbuzz-1.3.4.tar.bz2 --quiet
tar -xjf harfbuzz-1.3.4.tar.bz2
@ -119,12 +174,10 @@ jobs:
fontforge --version
fontforge --version 2>&1 | grep libfontforge | awk '{print $NF}'
- name: Bump version for source files once
# @todo fixme - put in a separate job with the release env setup and output the release info
if: ${{ matrix.font == '3270' }}
- name: Bump version for source files
run: |
cd -- "$GITHUB_WORKSPACE/bin/scripts"
./version-bump.sh "$RELEASE_TAG_VERSION"
./version-bump.sh "$RELEASE_VERSION"
- name: Standardize the readme files
run: |
@ -137,17 +190,25 @@ jobs:
fontforge --script `pwd`/../../font-patcher --version
./gotta-patch-em-all-font-patcher\!.sh "/${{ matrix.font }}"
- name: Generate fontconfig and casks
run: |
cd -- "$GITHUB_WORKSPACE/bin/scripts"
./generate-fontconfig.sh
./generate-casks.sh "${{ matrix.font }}"
- name: Archive font package zip files and upload for release
- name: Archive font package zip files
run: |
cd -- "$GITHUB_WORKSPACE/bin/scripts"
./archive-fonts.sh "${{ matrix.font }}"
GITHUB_TOKEN=$GITHUB_TOKEN PRERELEASE=$RELEASE_CANDIDATE ./upload-archives.sh $RELEASE_TAG_VERSION "${{ matrix.font }}"
- name: Generate cask
# The casks are not used at the moment, but probably Ryan
# wanted to push them out somewhere
run: |
cd -- "$GITHUB_WORKSPACE/bin/scripts"
./generate-casks.sh "${{ matrix.font }}"
- name: Upload zip file archive for release
uses: softprops/action-gh-release@v0.1.14
if: needs.setup-fonts-matrix.outputs.rel_upload == 'true'
with:
prerelease: ${{ env.RELEASE_CANDIDATE != 'false' }}
tag_name: "v${{ env.RELEASE_VERSION }}"
files: archives/*
- name: Upload patched fonts as artifacts
uses: actions/upload-artifact@v2
@ -159,42 +220,50 @@ 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: |
casks/${{ matrix.font }}
LICENSE
release-font-patcher:
name: Archive font patcher and add to release
needs: build
needs: [ setup-fonts-matrix, build ]
env:
GITHUB_ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
RELEASE_VERSION: ${{ needs.setup-fonts-matrix.outputs.rel_version }}
RELEASE_CANDIDATE: ${{ needs.setup-fonts-matrix.outputs.rel_candidate }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set release variables
- name: Bump version for source files
run: |
cd -- "$GITHUB_WORKSPACE"
cat package.json
RELEASE_TAG_VERSION=$(cat package.json \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')
echo "RELEASE_TAG_VERSION=$RELEASE_TAG_VERSION" >> $GITHUB_ENV
[[ "$RELEASE_TAG_VERSION" == *"-RC"* ]] && echo "RELEASE_CANDIDATE=true" || echo "RELEASE_CANDIDATE=false" >> $GITHUB_ENV
cd -- "$GITHUB_WORKSPACE/bin/scripts"
./version-bump.sh "$RELEASE_VERSION"
- name: Archive font-patcher script for release
run: |
cd -- "$GITHUB_WORKSPACE/bin/scripts"
./archive-font-patcher.sh
- name: Archive font package zip files and upload for release
run: |
cd -- "$GITHUB_WORKSPACE/bin/scripts"
GITHUB_TOKEN=$GITHUB_TOKEN PRERELEASE=$RELEASE_CANDIDATE ./upload-archives.sh $RELEASE_TAG_VERSION "FontPatcher"
- name: Upload font-patcher archive for release
uses: softprops/action-gh-release@v0.1.14
if: needs.setup-fonts-matrix.outputs.rel_upload == 'true'
with:
prerelease: ${{ env.RELEASE_CANDIDATE != 'false' }}
tag_name: "v${{ env.RELEASE_VERSION }}"
files: archives/*
commit:
name: Commit and push patched fonts to the repo
needs: build
needs: [ setup-fonts-matrix, build ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
@ -210,9 +279,50 @@ jobs:
name: patched-fonts
path: .
- uses: EndBug/add-and-commit@v9
- name: Bump version for source files
env:
RELEASE_VERSION: ${{ needs.setup-fonts-matrix.outputs.rel_version }}
RELEASE_CANDIDATE: ${{ needs.setup-fonts-matrix.outputs.rel_candidate }}
run: |
cd -- "$GITHUB_WORKSPACE/bin/scripts"
./version-bump.sh "$RELEASE_VERSION"
- name: Commit version bump changes
# If there are no changes (i.e. we already have that bump commit from a previous run)
# the git commit will fail as empty commit (that we do not explicitely allow here),
# and the action fails silently (i.e. without stopping the job).
# This means there will be only one commit in the repo for each version tag change,
# regardless of how often we run the release CI.
uses: EndBug/add-and-commit@v9
with:
add: 'patched-fonts'
message: Rebuilds patched fonts
add: "['font-patcher', 'bin/scripts']"
message: "[ci] Bump release version"
committer_name: GitHub Actions
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
- name: Commit patched fonts back to repo
uses: EndBug/add-and-commit@v9
with:
add: 'patched-fonts'
message: "[ci] Rebuilds patched fonts"
committer_name: GitHub Actions
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
- name: Generate fontconfig
run: |
cd -- "$GITHUB_WORKSPACE/bin/scripts"
./generate-fontconfig.sh
- name: Commit fontconfig back to repo
uses: EndBug/add-and-commit@v9
with:
add: '10-nerd-font-symbols.conf'
message: "[ci] Regenerate fontconfig"
committer_name: GitHub Actions
committer_email: 41898282+github-actions[bot]@users.noreply.github.com
- name: Adjust release tag to include previous commit
uses: EndBug/latest-tag@v1.5.0
if: needs.setup-fonts-matrix.outputs.rel_upload == 'true'
with:
ref: "v${{ needs.setup-fonts-matrix.outputs.rel_version }}"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Nerd Fonts Version: 2.1.0
# Script Version: 1.1.1
# Script Version: 1.1.2
# Iterates over all patched fonts directories
# to generate ruby cask files for homebrew-fonts (https://github.com/caskroom/homebrew-fonts)
# adds Windows versions of the fonts as well (casks files just won't download them)
@ -48,7 +48,7 @@ find "${outputdir:?}" -name "$search_pattern" -type f -delete
#find ./ProFont -maxdepth 0 -type d | # uncomment to test 1 font
# find ./IBMPlexMono -maxdepth 0 -type d | # uncomment to test 1 font
# uncomment to test all fonts:
find -- * -maxdepth 0 -iregex "$pattern" -type d |
find . -maxdepth 1 -iregex "\./$pattern" -type d |
while read -r filename
do
@ -71,14 +71,14 @@ do
# we can copy the font files without full paths but not necessarily the license files:
# add license files separately:
# zip -9 "$outputdir/$basename" -rj "$searchdir" -i '*license*' -i '*LICENSE*'
# work around to copy duplicate license files (only the last duplicate found)
# work around to copy duplicate license files (only the last duplicate found)
# so we don't have to copy entire paths and can still use the junk option (-j)
find "$searchdir" -type f -iname "*license*" | awk -F/ '{a[$NF]=$0}END{for(i in a)print a[i]}' | zip -9 -j "$outputdir/$basename" -@
fi;
# add mini readme file
zip -9 "$outputdir/$basename" -rj "$mini_readme" -q
rm -f "$mini_readme"
done
rm -f "$mini_readme"
ls -al "$outputdir"
ls -al "$outputdir"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Nerd Fonts Version: 2.1.0
# Script Version: 1.0.0
# Script Version: 1.0.1
# Iterates over all patched fonts directories
# to generate ruby cask files for homebrew-fonts (https://github.com/caskroom/homebrew-fonts)
# only adds non-Windows versions of the fonts
@ -80,9 +80,14 @@ function write_footer {
} >> "$outputfile"
}
pattern=$1
if [ "$pattern" = "" ]; then
pattern=".*"
fi
#find ./Hack -maxdepth 0 -type d | # uncomment to test 1 font
#find ./ProFont -maxdepth 2 -type d | # uncomment to test 1 font
find . -maxdepth 1 -mindepth 1 -type d | # uncomment to test 1 font
find . -maxdepth 1 -mindepth 1 -type d -iregex "\./$pattern" |
while read -r filename
do
@ -90,23 +95,22 @@ do
basename=$(basename "$filename")
sha256sum=$(sha256sum "../archives/${basename}.zip" | head -c 64)
searchdir=$filename
fontdir=$(basename "$(dirname "$dirname")")
MONOFONTS=()
while IFS= read -d $'\0' -r file ; do
MONOFONTS=("${MONOFONTS[@]}" "$file")
done < <(find "$searchdir" -type f -iwholename '*complete*' \( -iname '*.[o,t]tf' ! -wholename '*Windows*' -iname '*mono.*' \) -print0)
done < <(find "$searchdir" -type f -iwholename '*complete*' \( -iname '*.[o,t]tf' ! -wholename '*Windows*' -iname '*complete mono*' \) -print0)
FONTS=()
while IFS= read -d $'\0' -r file ; do
FONTS=("${FONTS[@]}" "$file")
done < <(find "$searchdir" -type f -iwholename '*complete*' \( -iname '*.[o,t]tf' ! -wholename '*Windows*' ! -iwholename '*mono.*' \) -print0)
done < <(find "$searchdir" -type f -iwholename '*complete*' \( -iname '*.[o,t]tf' ! -wholename '*Windows*' ! -iname '*complete mono*' \) -print0)
outputdir=$PWD/../casks/
formattedbasename=$(echo "$basename" | tr "[:upper:]" "[:lower:]")
echo "$LINE_PREFIX Generating cask for: $fontdir"
echo "$LINE_PREFIX Generating cask for: $basename"
[[ -d "$outputdir" ]] || mkdir -p "$outputdir"

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Nerd Fonts Version: 2.1.0
# Script Version: 1.0.0
# Script Version: 1.0.1
# Iterates over all patched fonts directories
# to generate a fontconfig based on the Nerd Fonts Symbols font
# that contains only the glyphs
@ -41,7 +41,7 @@ echo "$LINE_PREFIX Generating fontconfig for: monospace"
} >> "$to"
#find ./Hack -maxdepth 0 -type d | # uncomment to test 1 font
find . -maxdepth 1 -type d | # uncomment to get all fonts
find . -maxdepth 1 -type d | sort | # uncomment to get all fonts
while read -r filename
do

View File

@ -1,6 +1,8 @@
#!/usr/bin/env bash
# Nerd Fonts Version: 2.1.0
# calls the necessary scripts in the necessary order to prepare for a release
#
# This is not used for production
#set -x
LINE_PREFIX="# [Nerd Fonts] "
@ -18,7 +20,7 @@ release=$1
./generate-fontconfig.sh
./generate-casks.sh
./archive-fonts.sh
#./upload-archives.sh # better done as a separate step
#./upload-archives.sh # better done as a separate step (via gh action)
exit

View File

@ -1,88 +0,0 @@
#!/usr/bin/env bash
# Nerd Fonts Version: 2.1.0
# Script Version: 1.2.0
# Iterates over all archives and uploads to given release
# uncomment to debug:
#set -x
LINE_PREFIX="# [Nerd Fonts] "
cd ../../archives/ || {
echo >&2 "$LINE_PREFIX Could not find archives directory"
exit 1
}
# We don't need to use a separate access token for accessing Github API when we
# are in a Github action, can use the auto provided `GITHUB_TOKEN`
# see: https://docs.github.com/en/actions/security-guides/automatic-token-authentication
TOKEN=$GITHUB_TOKEN
OWNER="ryanoasis"
REPO="nerd-fonts"
RELEASE_TAG=""
if [ -z "$1" ]
then
# before we used to check for tag param and set release URL to releases/latest
# but to simplify things let's just fail and always require a proper release/tag
echo "$LINE_PREFIX No Tag Release was given"
exit 1
else
echo "$LINE_PREFIX Tag/Release was $1"
RELEASE_TAG="$1"
fi
if [ -z "$2" ]
then
search_pattern="*.zip"
echo "$LINE_PREFIX No limiting pattern given, will search entire folder"
else
pattern=$2
search_pattern="*$2*.zip"
echo "$LINE_PREFIX Limiting upload archive to pattern '$pattern'"
fi
CURL_DATA="\"tag_name\":\"${RELEASE_TAG}\""
if [ "$PRERELEASE" == "true" ]
then
CURL_DATA+=", \"prerelease\": true"
fi
RELEASE_URL="https://api.github.com/repos/${OWNER}/${REPO}/releases/tags/${RELEASE_TAG}"
#if [ "$LAST_RELEASE_ID" = null]
# then
# @TODO add error checking around creating new release if release/tag already exists
echo "$LINE_PREFIX Creating new release/tag of ${RELEASE_TAG}"
curl \
-H "Authorization:token $TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/$OWNER/$REPO/releases \
-d "{$CURL_DATA}"
#else
# echo "$LINE_PREFIX A release did exist and the most recent release id was '$RELEASE'"
#fi
LAST_RELEASE_ID=$(curl -# -XGET -H "Authorization:token $TOKEN" -H 'Content-Type: application/json' "$RELEASE_URL" | jq -r '.id')
echo "$LINE_PREFIX The last release id was $LAST_RELEASE_ID"
#find ./Hack -maxdepth 0 -type d | # uncomment to test 1 font
find ./ -name "$search_pattern" | # uncomment to test all font
while read -r filename
do
basename=$(basename "$filename")
printf "$LINE_PREFIX Uploading %s \n" "$basename"
curl \
-# -XPOST \
-H "Authorization:token $TOKEN" \
-H "Content-Type:application/octet-stream" \
--data-binary @"$basename" https://uploads.github.com/repos/"$OWNER"/"$REPO"/releases/"$LAST_RELEASE_ID"/assets?name="$basename"
#exit # uncomment to test only 1 zip
done

View File

@ -1,6 +1,6 @@
#!/usr/bin/env bash
# Nerd Fonts Version: 2.1.0
# Script Version: 1.0.1
# Script Version: 1.0.2
# bump version number for release in scripts (bash and python)
# does not do semver format checking
# this obviously is not perfect but works good enough for now (YAGNI)
@ -18,13 +18,12 @@ release=$1
echo "$LINE_PREFIX Bump version to $release"
sed -i "s|[0-9]\\.[0-9]\\.[0-9]|$release|g" ../../font-patcher
sed -i "s|\\# Nerd Fonts Version: [0-9]\\.[0-9]\\.[0-9]|\\# Nerd Fonts Version: $release|g" ../../bin/scripts/**/*.sh
sed -i "s|\\# Nerd Fonts Version: [0-9]\\.[0-9]\\.[0-9]|\\# Nerd Fonts Version: $release|g" ../../bin/scripts/**/*.py
sed -i "s|\\# Nerd Fonts Version: [0-9]\\.[0-9]\\.[0-9]|\\# Nerd Fonts Version: $release|g" ../../bin/scripts/*.sh
sed -i "s|\\# Nerd Fonts Version: [0-9]\\.[0-9]\\.[0-9]|\\# Nerd Fonts Version: $release|g" ../../bin/scripts/*.py
sed -i "s|\\# version: [0-9]\\.[0-9]\\.[0-9]|\\# version: $release|g" ../../bin/scripts/*.sh
sed -i "s|version=\"[0-9]\\.[0-9]\\.[0-9]\"|version=\"$release\"|g" ../../bin/scripts/*.sh
exit
function patch_file {
echo patching $1
sed -i -E "s/^(# Nerd Fonts Version: )[0-9]+\.[0-9]+\.[0-9]+.*/\1$release/" "$1"
sed -i -E "s/^(version *= *\")[0-9]+\.[0-9]+\.[0-9]+.*(\") *$/\1$release\2/" "$1"
}
while IFS= read -r file; do
patch_file "$file"
done < <(find ../.. -name "*.sh" -o -name "*.py" -o -name "font-patcher" -type f)

View File

@ -1,10 +1,13 @@
#!/usr/bin/env python
# coding=utf8
# Nerd Fonts Version: 2.1.0
# script version: 3.0.1
# Script version is further down
from __future__ import absolute_import, print_function, unicode_literals
# Change the script version when you edit this script:
script_version = "3.0.2"
version = "2.1.0"
projectName = "Nerd Fonts"
projectNameAbbreviation = "NF"
@ -196,7 +199,7 @@ class font_patcher:
def patch(self):
print("{} Patcher v{} executing\n".format(projectName, version))
print("{} Patcher v{} ({}) executing\n".format(projectName, version, script_version))
if self.args.single:
# Force width to be equal on all glyphs to ensure the font is considered monospaced on Windows.