-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Setup release workflow * Update status badge * Move release workflow to the right directory
- Loading branch information
Showing
10 changed files
with
5,879 additions
and
107 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
use flake |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Release | ||
|
||
on: | ||
workflow_run: | ||
workflows: [Build] | ||
types: [completed] | ||
|
||
concurrency: | ||
group: release | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
release: | ||
if: ${{ github.event.workflow_run.conclusion == 'success' }} | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
- name: Install Nix | ||
uses: DeterminateSystems/nix-installer-action@v6 | ||
- name: Install tools via Nix | ||
run: nix develop --check | ||
- name: Install dependencies | ||
run: nix develop -c npm ci | ||
- name: Run semantic-release | ||
run: nix develop -c npx semantic-release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
.direnv | ||
node_modules | ||
templates/*/flake.lock |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
branches: [main] | ||
plugins: | ||
- "@semantic-release/commit-analyzer" | ||
- "@semantic-release/release-notes-generator" | ||
- ["@semantic-release/github", { successComment: false }] |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,97 +1,113 @@ | ||
{ | ||
inputs.nixpkgs-lib.url = "github:nixos/nixpkgs/nixos-23.05?dir=lib"; | ||
inputs = { | ||
flake-utils.url = "github:numtide/flake-utils"; | ||
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05"; | ||
}; | ||
|
||
outputs = { self, nixpkgs-lib }: | ||
let | ||
lib = nixpkgs-lib.lib; | ||
in | ||
{ | ||
lib.packagesFromVersionsFile = | ||
{ versionsFile | ||
, system ? builtins.currentSystem | ||
, plugins ? { } | ||
, skipMissingPlugins ? false | ||
}: | ||
outputs = { self, flake-utils, nixpkgs }: | ||
flake-utils.lib.eachDefaultSystem | ||
(system: | ||
let | ||
fileLines = file: lib.splitString "\n" (lib.fileContents file); | ||
removeComments = builtins.filter (line: !lib.hasPrefix "#" line); | ||
parseVersions = builtins.map | ||
(line: | ||
let | ||
pluginAndVersion = lib.splitString " " line; | ||
in | ||
{ | ||
name = builtins.elemAt pluginAndVersion 0; | ||
version = builtins.elemAt pluginAndVersion 1; | ||
}); | ||
filterPlugins = builtins.filter | ||
({ name, ... }: | ||
let | ||
hasPlugin = builtins.hasAttr name plugins; | ||
in | ||
lib.throwIf (!skipMissingPlugins && !hasPlugin) | ||
'' | ||
No plugin found for "${name}", try adding the missing plugin: | ||
pkgs = nixpkgs.legacyPackages.${system}; | ||
in | ||
{ | ||
devShells.default = pkgs.mkShell { | ||
buildInputs = [ pkgs.nodejs ]; | ||
}; | ||
}) | ||
// | ||
( | ||
let | ||
lib = nixpkgs.lib; | ||
in | ||
{ | ||
lib.packagesFromVersionsFile = | ||
{ versionsFile | ||
, system ? builtins.currentSystem | ||
, plugins ? { } | ||
, skipMissingPlugins ? false | ||
}: | ||
let | ||
fileLines = file: lib.splitString "\n" (lib.fileContents file); | ||
removeComments = builtins.filter (line: !lib.hasPrefix "#" line); | ||
parseVersions = builtins.map | ||
(line: | ||
let | ||
pluginAndVersion = lib.splitString " " line; | ||
in | ||
{ | ||
name = builtins.elemAt pluginAndVersion 0; | ||
version = builtins.elemAt pluginAndVersion 1; | ||
}); | ||
filterPlugins = builtins.filter | ||
({ name, ... }: | ||
let | ||
hasPlugin = builtins.hasAttr name plugins; | ||
in | ||
lib.throwIf (!skipMissingPlugins && !hasPlugin) | ||
'' | ||
No plugin found for "${name}", try adding the missing plugin: | ||
``` | ||
<asdf2nix>.lib.packagesFromVersionsFile { | ||
plugins = { | ||
${name} = <asdf2nix-${name}>.lib.packageFromVersion; | ||
``` | ||
<asdf2nix>.lib.packagesFromVersionsFile { | ||
plugins = { | ||
${name} = <asdf2nix-${name}>.lib.packageFromVersion; | ||
... | ||
}; | ||
... | ||
}; | ||
... | ||
}; | ||
``` | ||
``` | ||
Or enable `skipMissingPlugins` to skip this error: | ||
Or enable `skipMissingPlugins` to skip this error: | ||
``` | ||
<asdf2nix>.lib.packagesFromVersionsFile { | ||
plugins = { ... }; | ||
skipMissingPlugins = true; | ||
... | ||
}; | ||
``` | ||
'' | ||
lib.warnIf | ||
(!hasPlugin) "Skipping \"${name}\" plugin" | ||
hasPlugin); | ||
findPackages = builtins.map | ||
({ name, version }: | ||
let | ||
plugin = plugins.${name}; | ||
in | ||
lib.throwIf (!plugin.hasVersion { inherit system version; }) | ||
'' | ||
Plugin "${name}" does not provide version "${version}", try | ||
updating the plugin's input: | ||
``` | ||
<asdf2nix>.lib.packagesFromVersionsFile { | ||
plugins = { ... }; | ||
skipMissingPlugins = true; | ||
... | ||
}; | ||
``` | ||
'' | ||
lib.warnIf | ||
(!hasPlugin) "Skipping \"${name}\" plugin" | ||
hasPlugin); | ||
findPackages = builtins.map | ||
({ name, version }: | ||
let | ||
plugin = plugins.${name}; | ||
in | ||
lib.throwIf (!plugin.hasVersion { inherit system version; }) | ||
'' | ||
Plugin "${name}" does not provide version "${version}", try | ||
updating the plugin's input: | ||
``` | ||
> nix flake lock --update-input <asdf2nix-${name}> | ||
``` | ||
'' | ||
{ | ||
inherit name; | ||
value = plugin.packageFromVersion { inherit system version; }; | ||
} | ||
); | ||
in | ||
builtins.listToAttrs | ||
(findPackages | ||
(filterPlugins | ||
(parseVersions | ||
(removeComments | ||
(fileLines versionsFile))))); | ||
``` | ||
> nix flake lock --update-input <asdf2nix-${name}> | ||
``` | ||
'' | ||
{ | ||
inherit name; | ||
value = plugin.packageFromVersion { inherit system version; }; | ||
} | ||
); | ||
in | ||
builtins.listToAttrs | ||
(findPackages | ||
(filterPlugins | ||
(parseVersions | ||
(removeComments | ||
(fileLines versionsFile))))); | ||
|
||
templates = { | ||
default = { | ||
description = "Install Nix packages from asdf versions file"; | ||
path = ./templates/default; | ||
}; | ||
devenv = { | ||
description = "Integration with devenv"; | ||
path = ./templates/devenv; | ||
templates = { | ||
default = { | ||
description = "Install Nix packages from asdf versions file"; | ||
path = ./templates/default; | ||
}; | ||
devenv = { | ||
description = "Integration with devenv"; | ||
path = ./templates/devenv; | ||
}; | ||
}; | ||
}; | ||
}; | ||
} | ||
); | ||
} |
Oops, something went wrong.