Skip to content

Commit

Permalink
Release (#1)
Browse files Browse the repository at this point in the history
* Update QMK - [GitHub Action]

* Validate QMK

* Fix format

* Fix action submodules

* Try to speed up builds by setting up a nix cache

* Fix cache key hash

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Add nix-community cache

* Set up cachix

* Remove concurrency check

* Skip cachix auto push

* Let cachix check what should be pushed
Plus, size estimation was way off

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Update QMK - [GitHub Action]

* Fix release

* Fix release (again)

* Add check workflow

* Fix job name

* Small fixes

* Enhance setup script

* Update QMK - [GitHub Action]

* Add format command
And reformat code to comply

* Fix format
Configuration was not being detected, and qmk filters some files

* Only release on relevant changes

* Update QMK - [GitHub Action]

* Fix workflow style

* Increase update frequency

* Fix update branch

* Try and test the full shell.nix logic

* Try to fix expressions

* Try even harder

* Maybe I overcomplicated things

* Fix the validation

* Disable setup since that requires root access

* Try to execute as much as possible

* Fix cache push

* Make linter readable

* Shorten comment

* Try to make final check more readable

* Fix expression?

* Fix style

* Use script's own update process

* Add some more words to the dictionary

* Rework initialisation

* Fix shell import to match convention

* Set up better default man pager

* Fix hardcoded value

* Use different keyboard for better portability test

* Better root dir detection

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
kip93 and github-actions[bot] authored Apr 10, 2022
1 parent f562cea commit 5889ef6
Show file tree
Hide file tree
Showing 12 changed files with 721 additions and 438 deletions.
146 changes: 146 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
name: Check code quality

on:
push:
branches: [ main, develop ]
paths:
- 'keymap/**'
- 'QMK'
- 'shell.nix'
- '.github/workflows/check.yml'
workflow_dispatch: {}

jobs:
check:
name: Check code quality
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
with:
submodules: recursive
path: ./repo

- name: Set up Nix
uses: cachix/install-nix-action@v15
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command
- name: Set up cache
uses: cachix/cachix-action@v10
with:
name: kip93
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
extraPullNames: nix-community
skipPush: true

- name: Print nixpkgs version
run: |
nix-instantiate --eval -E '"nixpkgs version: ${(import <nixpkgs> {}).lib.version}"'
- name: Shellcheck shell.nix
id: shellcheck
working-directory: ./repo
run: |
(
printf '#!/bin/bash\n' ;
nix-shell --pure shell.nix --run : >/dev/null ;
nix-instantiate shell.nix 2>/dev/null | xargs -i sed '1,5d' {} ;
) | nix-shell -p shellcheck --run 'shellcheck -'
continue-on-error: true

- name: QMK Format
id: qmk-format
working-directory: ./repo
run: |
nix-shell --run format
git diff --exit-code --name-only
continue-on-error: true

- name: QMK Lint
id: qmk-lint
working-directory: ./repo
run: |
nix-shell --run lint
continue-on-error: true

- name: Check shell.nix format
id: nixpkgs-fmt
working-directory: ./repo
run: |
nix-shell -p nixpkgs-fmt --run 'nixpkgs-fmt --check shell.nix'
continue-on-error: true

- name: Lint shell.nix
id: nix-linter
working-directory: ./repo
run: |
nix-shell -p nix-linter --run ' \
nix-linter -W no-AlphabeticalArgs \
-W no-AlphabeticalBindings \
-W BetaReduction \
-W DIYInherit \
-W EmptyInherit \
-W EmptyLet \
-W no-EmptyVariadicParamSet \
-W FreeLetInFunc \
-W LetInInheritRecset \
-W no-ListLiteralConcat \
-W NegateAtom \
-W SequentialLet \
-W SetLiteralUpdate \
-W UnfortunateArgName \
-W no-UnneededAntiquote \
-W UnneededRec \
-W UnusedArg \
-W UnusedLetBind \
-W UpdateEmptySet \
-v shell.nix \
'
continue-on-error: true

- name: Check shell.nix for vulnerabilities
id: vulnix
working-directory: ./repo
run: |
nix-shell -p vulnix --run 'vulnix -f shell.nix'
continue-on-error: true

- name: Validate shell.nix logic
id: validate
working-directory: .
run: |
(
mkdir -p ./tmp ;
cp ./repo/shell.nix ./tmp/shell.nix ;
sed -i -E 's|\bKEYBOARD\b\s*=\s*".+?"\s*;|KEYBOARD = "ergodox_ez";|' ./tmp/shell.nix ;
cd ./tmp ;
MANPAGER=cat nix-shell --run help ;
nix-shell --pure --run init ;
# nix-shell --pure --run setup ; # No root access, but not needed since we won't be flashing
nix-shell --pure --run format ;
nix-shell --pure --run lint ;
nix-shell --pure --run compile ;
# nix-shell --pure --run flash ; # Can't flash since there is no keyboard attached
nix-shell --pure --run clean ;
)
continue-on-error: true

- name: Check for failures
if: |
steps.shellcheck.outcome != 'success' ||
steps.qmk-format.outcome != 'success' ||
steps.qmk-lint.outcome != 'success' ||
steps.nixpkgs-fmt.outcome != 'success' ||
steps.nix-linter.outcome != 'success' ||
steps.vulnix.outcome != 'success' ||
steps.validate.outcome != 'success'
run: exit 1

- name: Push to cache
working-directory: ./repo
run: |
nix-shell --pure shell.nix --run :
nix-store -qR --include-outputs $(nix-instantiate shell.nix 2>/dev/null) | cachix push kip93
67 changes: 46 additions & 21 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
name: Release

on:
push: { branches: [ main, develop ] }
push:
branches: [ main, develop ]
paths:
- 'keymap/**'
- 'QMK'
- 'shell.nix'
- '.github/workflows/release.yml'
workflow_dispatch: {}

concurrency:
Expand All @@ -22,58 +28,77 @@ jobs:
uses: cachix/install-nix-action@v15
with:
nix_path: nixpkgs=channel:nixos-unstable

- name: Set up cache
uses: cachix/cachix-action@v10
with:
name: kip93
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
extraPullNames: nix-community
skipPush: true

- name: Print nixpkgs version
run: |
nix-instantiate --eval -E '"nixpkgs version: ${(import <nixpkgs> {}).lib.version}"'
- name: Compile
run: nix-shell --run compile
run: |
nix-shell --pure --run compile
- name: Create tag
id: tag
run: |
TAG="$(date '+v%y.%m.%d.%H%M%S')${{ github.ref != 'refs/heads/main' && '-RC' || '' }}"
git tag "${TAG}"
git push --tags
printf 'Tagged: %s -> %s.\n\n' "$(git rev-parse HEAD)" "${TAG}"
printf '::set-output name=tag::%s\n' "${TAG}"
- name: Create changelog
run: |
git fetch --tags
printf 'Reference:\n'
printf '%s.\n\n' "${GITHUB_REF}"
printf 'Branch:\n'
printf '%s\n\n' "${GITHUB_REF_NAME}"
printf 'Latest tags:\n'
git tag -l --sort=version:refname | tail -10
git fetch --tags
git tag -l --sort=-version:refname | head -10
printf '\n'
printf 'Latest full release tags:\n'
git tag -l --sort=version:refname | grep -P '^v\\d{2}\\.\\d{2}\\.\\d{2}\\.\\d{6}$' | tail -10
git tag -l --sort=-version:refname | grep -P '^v\d{2}\.\d{2}\.\d{2}\.\d{6}$' | head -10
printf '\n'
printf '[Commits to %s since this release]' "${GITHUB_REF_NAME}" >>'.build/CHANGELOG.md'
printf '(%s/%s/compare/' "${GITHUB_SERVER_URL}" "${GITHUB_REPOSITORY}" >>'.build/CHANGELOG.md'
printf '%s...%s)' "${{ steps.tag.outputs.tag }}" "${GITHUB_REF_NAME}" >>'.build/CHANGELOG.md'
printf '\n\n' >>'.build/CHANGELOG.md'
printf 'Changelog:\n'
if [ "${GITHUB_REF_NAME}" = 'main' ] && [ "$(git tag -l | grep -P '^v\d{2}\.\d{2}\.\d{2}\.\d{6}$' | wc -l)" -ge 2 ] ; then
LAST_TAG="$(git tag -l --sort=-version:refname | grep -P '^v\d{2}\.\d{2}\.\d{2}\.\d{6}$' | sed -n '2{p;q;}')"
elif [ "$(git tag -l | wc -l)" -ge 2 ] ; then
LAST_TAG="$(git tag -l --sort=-version:refname | sed -n '2{p;q;}')"
else
LAST_TAG="$(git rev-list --max-parents=0 HEAD)"
fi
printf '%s...%s\n\n' "${{ steps.tag.outputs.tag }}" "${LAST_TAG}"
printf '[Full changelog]' >>'.build/CHANGELOG.md'
printf '(%s/%s/compare/' "${GITHUB_SERVER_URL}" "${GITHUB_REPOSITORY}" >>'.build/CHANGELOG.md'
if [ "${GITHUB_REF_NAME}" = 'main' ] && [ "$(git tag -l | grep -P '^v\\d{2}\\.\\d{2}\\.\\d{2}\\.\\d{6}$' | wc -l)" -ge 2 ] ; then
printf '%s...%s)' "$(git tag -l --sort=version:refname | grep -P '^v\\d{2}\\.\\d{2}\\.\\d{2}\\.\\d{6}$' | tail -2 | head -1)" "${{ steps.tag.outputs.tag }}" >>'.build/CHANGELOG.md'
elif [ "$(git tag -l | wc -l)" -ge 2 ] ; then
printf '%s...%s)' "$(git tag -l --sort=version:refname | tail -2 | head -1)" "${{ steps.tag.outputs.tag }}" >>'.build/CHANGELOG.md'
printf '%s...%s)\n\n' "${LAST_TAG}" "${{ steps.tag.outputs.tag }}" >>'.build/CHANGELOG.md'
else
printf '%s...%s)' "$(git rev-list --max-parents=0 HEAD)" "${{ steps.tag.outputs.tag }}" >>'.build/CHANGELOG.md'
fi
printf '\n\n' >>'.build/CHANGELOG.md'
printf '[Commits to %s since this release]' "${GITHUB_REF_NAME}" >>'.build/CHANGELOG.md'
printf '(%s/%s/compare/' "${GITHUB_SERVER_URL}" "${GITHUB_REPOSITORY}" >>'.build/CHANGELOG.md'
printf '%s...%s)\n\n' "${{ steps.tag.outputs.tag }}" "${GITHUB_REF_NAME}" >>'.build/CHANGELOG.md'
- name: Publish release
uses: softprops/action-gh-release@v1
with:
files: |
.build/firmware.hex
./.build/firmware.hex
fail_on_unmatched_files: true
name: ${{ steps.tag.outputs.tag }}
tag_name: ${{ steps.tag.outputs.tag }}
body_path: .build/CHANGELOG.md
prerelease: ${{ github.ref != 'refs/heads/main' }}

- name: Push to cache
run: |
nix-shell --pure shell.nix --run :
nix-shell --pure QMK/shell.nix --run :
nix-store -qR --include-outputs $(nix-instantiate shell.nix QMK/shell.nix 2>/dev/null) | cachix push kip93
39 changes: 35 additions & 4 deletions .github/workflows/update.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Update QMK

on:
schedule: [ { cron: "42 */4 * * *" } ]
schedule: [ { cron: "42 * * * *" } ] # Every hour, past 42 minutes to avoid peak times.
workflow_dispatch: {}

concurrency:
Expand All @@ -14,15 +14,46 @@ jobs:
steps:
- name: Checkout repository
uses: actions/checkout@v3
with: { ref: "develop" }
with:
ref: develop
submodules: recursive

- name: Update
run: |
git submodule update --init --remote QMK
nix-shell --pure --run update
- name: Set up Nix
uses: cachix/install-nix-action@v15
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command
- name: Set up cache
uses: cachix/cachix-action@v10
with:
name: kip93
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}'
extraPullNames: nix-community
skipPush: true

- name: Print nixpkgs version
run: |
nix-instantiate --eval -E '"nixpkgs version: ${(import <nixpkgs> {}).lib.version}"'
- name: Validate
run: |
nix-shell --pure --run compile
- name: Commit
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git remote set-url origin "https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}"
git remote set-url origin \
"https://x-access-token:${{ github.token }}@github.com/${{ github.repository }}"
git commit -am "Update QMK - [GitHub Action]" && git push || true
- name: Push to cache
run: |
nix-shell --pure QMK/shell.nix --run :
nix-store -qR --include-outputs $(nix-instantiate QMK/shell.nix 2>/dev/null) | cachix push kip93
6 changes: 6 additions & 0 deletions .vscode/ltex.dictionary.en-GB.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
cachix
Corne
github
keycaps
Keyhive
keymap
keymaps
MCUs
nix
nixos
nixpkgs
ortholinear
QMK
2 changes: 1 addition & 1 deletion QMK
Submodule QMK updated 2056 files
Loading

0 comments on commit 5889ef6

Please sign in to comment.