Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
feat(github-actions): move to release action
Browse files Browse the repository at this point in the history
  • Loading branch information
florian-sanders-cc committed Apr 6, 2024
1 parent 5105c1f commit 60fb4a4
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 23 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/nix-flake-update-node-version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Update node version - nix flake
on:
push:
branches:
- master
- 'hotfix/**'
jobs:
check-node-version:
runs-on: ubuntu-latest
outputs:
NODE_VERSION: ${{ steps.prefetch.outputs.NODE_VERSION }}
steps:
- uses: actions/checkout@v4
- id: get_package_json_content
run: echo "PACKAGE_JSON_CONTENT=$(cat ./package.json)" >> $GITHUB_OUTPUT
- id: extract_node_version
run: echo "NODE_VERSION=${{ fromJSON(steps.get_package_json_content.outputs.PACKAGE_JSON_CONTENT).volta.node }}" >> $GITHUB_OUTPUT
- name: output node version
run: echo ${{ steps.extract_node_version.NODE_VERSION }}
34 changes: 34 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,42 @@ on:
- master
- 'hotfix/**'
jobs:
update-nix-flake:
runs-on: ubuntu-latest
outputs:
NPM_DEPS_HASH: ${{ steps.prefetch.outputs.NPM_DEPS_HASH }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.WORKFLOW_GIT_ACCESS_TOKEN }}
- name: Install Nix
uses: cachix/install-nix-action@v26
with:
github_access_token: ${{ secrets.PERSO_TOKEN }}
nix_path: nixpkgs=channel:nixos-unstable
- name: Install prefetch-npm-deps
run: nix-env -i prefetch-npm-deps -f '<nixpkgs>'
- name: prefetch
id: prefetch
run: echo "NPM_DEPS_HASH=$(prefetch-npm-deps package-lock.json)" >> $GITHUB_OUTPUT
- name: escape
id: escape
run: echo "NPM_DEPS_HASH_ESCAPED=$(echo ${{ steps.prefetch.outputs.NPM_DEPS_HASH }} | sed 's/\//\\\\\//gip')" >> $GITHUB_OUTPUT
- name: update
run: sed -i "s/sha[^\"]\+/${{ steps.escape.outputs.NPM_DEPS_HASH_ESCAPED }}/" flake.nix
- name: check for update
run: if [-n $(git status --porcelain)] then

- run: git add .
- run: nix flake update
- run: |
git config --global user.name 'Florian Sanders'
git config --global user.email 'florian.sanders@clever-cloud.com'
git commit -m "chore(flake): update nix flake"
git push
release-please:
runs-on: ubuntu-latest
needs: update-nix-flake
steps:
- uses: google-github-actions/release-please-action@v3
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-flake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
- master
- 'hotfix/**'
jobs:
Prefetch-npm-deps:
update-nix-flake:
runs-on: ubuntu-latest
outputs:
NPM_DEPS_HASH: ${{ steps.prefetch.outputs.NPM_DEPS_HASH }}
Expand Down
3 changes: 3 additions & 0 deletions TODO.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- [ ] action to check if node version has changed => I would say do it after a merge?
- [ ] action to check dependencies => I would say do it after a merge or before a merge?
- [ ] action to check update flake.lock & suggest updating => I would say do it after a merge?
28 changes: 7 additions & 21 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,17 @@

outputs = inputs @ { self, nixpkgs, systems, ... }: {
defaultPackage.x86_64-linux = with import nixpkgs { system = "x86_64-linux"; };
stdenv.mkDerivation (finalAttrs: {
buildNpmPackage rec {
pname = "clever-tools";
version = "3.4.0";

src = ./.;

cleverTools = buildNpmPackage {
name = finalAttrs.pname;
src = ./.;
rev = "be0db0115a1f2cf2899e67517b9fcb7c3e1f6edc";
npmDepsHash = "sha256-Ca8emrCdIaQ4oKYc8u00BW7WdcINKv1tAnJE8ppsuFw=";
dontNpmBuild = true;
};
nodejs = nodejs-18_x;

installPhase = ''
cp -r ${finalAttrs.cleverTools} $out
'';

nativeBuildInputs = [
nodejs
];
src = ./.;

buildInputs = [
nodejs
];
rev = "be0db0115a1f2cf2899e67517b9fcb7c3e1f6edc";
npmDepsHash = "sha256-Ca8emrCdIaQ4oKYc8u00BW7WdcINKv1tAnJE8ppsuFw=";
dontNpmBuild = true;

meta = {
description = "";
Expand All @@ -42,7 +28,7 @@
maintainers = with lib.maintainers;
[ ];
};
});
};
};

}
2 changes: 1 addition & 1 deletion result

0 comments on commit 60fb4a4

Please sign in to comment.