Keep Releases in Cachix #786
This file contains hidden or 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
name: Keep Releases in Cachix | |
on: | |
push: | |
branches: master | |
schedule: | |
- cron: '0 17 * * *' | |
jobs: | |
build: | |
strategy: | |
matrix: | |
version: ["v1.3.0", "v1.2.0", "v1.1.0", "v1.0.1", "v1.0.0"] | |
os: [ubuntu-latest, macos-latest, ARM64] | |
runs-on: ${{ matrix.os }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: DeterminateSystems/nix-installer-action@main | |
with: | |
determinate: true | |
extra-conf: "lazy-trees = true" | |
if: matrix.os != 'ARM64' | |
- uses: cachix/cachix-action@v16 | |
with: | |
name: digitallyinduced | |
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}' | |
authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' | |
if: matrix.os != 'ARM64' | |
- run: git clone https://github.com/digitallyinduced/ihp-boilerplate.git | |
- run: | | |
cd ihp-boilerplate | |
git checkout ${{ matrix.version }} | |
if test -f flake.nix; then \ | |
nix develop --impure --command bash -c "new-application Web && make build/bin/RunUnoptimizedProdServer"; \ | |
else \ | |
nix-shell --run "new-application Web && make build/bin/RunUnoptimizedProdServer"; \ | |
fi; | |
- name: Build IHP app | |
run: | | |
cd ihp-boilerplate | |
if test -f flake.nix; then \ | |
nix develop --impure --profile ihp-boilerplate-profile --command "true"; \ | |
else \ | |
nix-shell --run "true"; \ | |
fi; | |
- name: Install jq | |
run: nix profile install nixpkgs#jq | |
if: matrix.os != 'ARM64' | |
- name: Push IHP app to cachix | |
run: | | |
cd ihp-boilerplate | |
if test -f flake.nix; then \ | |
cachix push digitallyinduced ihp-boilerplate-profile; \ | |
nix develop --impure --command bash -c 'make -s all; new-application Web'; \ | |
git add .; \ | |
nix build --json --impure | jq -r '.[].outputs | to_entries[].value' | cachix push digitallyinduced; \ | |
fi; | |
- name: Pin IHP Framework in Cachix | |
run: | | |
cd ihp-boilerplate | |
# Extract the IHP version we're working with | |
IHP_VERSION=${{ matrix.version }} | |
IHP_VERSION_CLEAN=${IHP_VERSION#v} | |
# For flake-based projects | |
if test -f flake.nix; then | |
# Build the development shell and capture all dependencies | |
nix develop --impure --profile ./temp-profile --command true | |
# Find IHP-related paths in the profile | |
IHP_PATHS=$(nix path-info -r ./temp-profile | grep -i "ihp-" || true) | |
# Push all found IHP paths to Cachix | |
if [ ! -z "$IHP_PATHS" ]; then | |
echo "$IHP_PATHS" | while read -r path; do | |
echo "Pushing and pinning: $path" | |
cachix push digitallyinduced "$path" | |
# Extract a meaningful name from the path | |
PATH_NAME=$(basename "$path" | sed 's/^[^-]*-//' | cut -d'-' -f1) | |
PIN_NAME="ihp-${PATH_NAME}-${IHP_VERSION_CLEAN}-${{ matrix.os }}" | |
# Pin this path in Cachix | |
cachix pin digitallyinduced "$PIN_NAME" "$path" | |
done | |
else | |
echo "No IHP paths found in the development environment" | |
fi | |
else | |
# For non-flake projects | |
nix-shell --run "true" | |
IHP_PATHS=$(nix-store -q --references $(nix-store -q --deriver $(which RunUnoptimizedProdServer)) | grep -i "ihp-" || true) | |
if [ ! -z "$IHP_PATHS" ]; then | |
echo "$IHP_PATHS" | while read -r path; do | |
echo "Pushing and pinning: $path" | |
cachix push digitallyinduced "$path" | |
# Extract a meaningful name from the path | |
PATH_NAME=$(basename "$path" | sed 's/^[^-]*-//' | cut -d'-' -f1) | |
PIN_NAME="ihp-${PATH_NAME}-${IHP_VERSION_CLEAN}-${{ matrix.os }}" | |
# Pin this path in Cachix | |
cachix pin digitallyinduced "$PIN_NAME" "$path" | |
done | |
fi | |
fi |