Skip to content

Commit fd63d84

Browse files
authored
Merge pull request #11 from phanirithvij/main
add gha workflow for releases
2 parents 7eed9c0 + 71b57db commit fd63d84

File tree

4 files changed

+135
-36
lines changed

4 files changed

+135
-36
lines changed

.github/dependabot.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "github-actions"
4+
directory: "/"
5+
schedule:
6+
interval: "weekly"
7+
day: "monday"
8+
time: "09:00"
9+
timezone: "UTC"
10+
open-pull-requests-limit: 5
11+
commit-message:
12+
prefix: "ci"
13+
include: "scope"
14+
rebase-strategy: "auto"
15+
groups:
16+
github-actions:
17+
patterns:
18+
- "*"
19+
update-types:
20+
- "minor"
21+
- "patch"

.github/workflows/artifact.yaml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/main.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Build and Release
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
7+
workflow_dispatch:
8+
inputs:
9+
version:
10+
description: "Release version (e.g., v1.0.0) - leave empty to auto-increment"
11+
required: false
12+
type: string
13+
increment:
14+
description: "How to increment version if not specified"
15+
required: false
16+
default: "minor"
17+
type: choice
18+
options:
19+
- patch
20+
- minor
21+
- major
22+
jobs:
23+
build:
24+
strategy:
25+
matrix:
26+
include:
27+
- arch: "x86_64-linux"
28+
os: ubuntu-latest
29+
- arch: "aarch64-linux"
30+
os: ubuntu-24.04-arm
31+
runs-on: ${{ matrix.os }}
32+
steps:
33+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
34+
- uses: cachix/install-nix-action@c202056c6d0293bbc1c45caaa531f8f918914e53 # v31
35+
- name: Building tarball for ${{ matrix.arch }}
36+
run: nix build
37+
- name: Uploading artifacts
38+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
39+
with:
40+
name: nixos-system-${{ matrix.arch }}.tar.xz
41+
path: result/tarball/nixos-system-${{ matrix.arch }}.tar.xz
42+
release:
43+
runs-on: ubuntu-latest
44+
if: github.event_name == 'workflow_dispatch'
45+
needs: build
46+
permissions:
47+
contents: write
48+
steps:
49+
- uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5
50+
with:
51+
fetch-depth: 0
52+
- name: Determine new version
53+
id: version
54+
run: |
55+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
56+
CLEAN_VERSION=${LATEST_TAG#v}
57+
if [[ -n "${{ github.event.inputs.version }}" ]]; then
58+
VERSION="${{ github.event.inputs.version }}"
59+
# Strip 'v' prefix if present, then add it back consistently
60+
CLEAN_VERSION=${INPUT_VERSION#v}
61+
VERSION="v$CLEAN_VERSION"
62+
echo "Using provided version: $VERSION"
63+
else
64+
# Ensure we have a full semver (pad with .0 if needed)
65+
case $(echo "$CLEAN_VERSION" | tr '.' '\n' | wc -l) in
66+
1) CLEAN_VERSION="$CLEAN_VERSION.0.0" ;;
67+
2) CLEAN_VERSION="$CLEAN_VERSION.0" ;;
68+
esac
69+
npm install -g semver
70+
NEW_VERSION=$(semver -i ${{ github.event.inputs.increment || 'minor' }} $CLEAN_VERSION)
71+
VERSION="v$NEW_VERSION"
72+
echo "Auto-incremented from $LATEST_TAG to: $VERSION"
73+
fi
74+
echo "version=$VERSION" >> $GITHUB_OUTPUT
75+
echo "prev_version=${LATEST_TAG}" >> $GITHUB_OUTPUT
76+
- name: Update README
77+
run: |
78+
sed -i 's/${{ steps.version.outputs.prev_version }}/${{ steps.version.outputs.version }}/g' README.md
79+
80+
git config --local user.name "github-actions[bot]"
81+
git config --local user.email "github-actions[bot]@users.noreply.github.com"
82+
git add README.md
83+
git diff --staged --quiet || git commit -m "update README.md"
84+
git push
85+
- name: Create tag
86+
run: |
87+
git tag ${{ steps.version.outputs.version }}
88+
git push origin ${{ steps.version.outputs.version }}
89+
- name: Download artifacts
90+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
91+
with:
92+
path: artifacts/
93+
- name: Create release
94+
run: |
95+
gh release create ${{ steps.version.outputs.version }} \
96+
--title "Release ${{ steps.version.outputs.version }}" \
97+
--notes "Release ${{ steps.version.outputs.version }}" \
98+
--latest \
99+
artifacts/*/nixos-system-*.tar.xz
100+
env:
101+
GH_TOKEN: ${{ secrets.GH_TOKEN }}

README.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,46 +9,48 @@ You don't need `nix` or NixOS to fetch and run the image:
99

1010
```sh
1111
# x86_64-linux architecture
12-
machinectl pull-tar https://github.com/tfc/nspawn-nixos/releases/download/v1.0/nixos-system-x86_64-linux.tar.xz nixos --verify=no
12+
machinectl pull-tar https://github.com/tfc/nspawn-nixos/releases/download/v1.2/nixos-system-x86_64-linux.tar.xz nixos --verify=no
1313

1414
# aarch64-linux architecture
15-
machinectl pull-tar https://github.com/tfc/nspawn-nixos/releases/download/v1.0/nixos-system-aarch64-linux.tar.xz nixos --verify=no
15+
machinectl pull-tar https://github.com/tfc/nspawn-nixos/releases/download/v1.2/nixos-system-aarch64-linux.tar.xz nixos --verify=no
1616

1717
machinectl start nixos
1818
# Set root password
1919
machinectl shell nixos /usr/bin/env passwd
2020
machinectl login nixos
2121
```
2222

23+
There are also nightly build artifacts available in the
24+
[github actions](https://github.com/phanirithvij/nspawn-nixos/actions/workflows/main.yml).
25+
2326
You can also change the configuration in this repository first, and then import
2427
a local build:
2528

2629
```sh
2730
machinectl import-tar $(nix build --print-out-paths)/tarball/* nixos
2831
```
2932

30-
If you want the container to use the host's network, create a configuration
31-
file like this:
33+
If you want the container to use the host's network, create a configuration file
34+
like this:
3235

3336
```sh
3437
printf "[Network]\nVirtualEthernet=no" > /etc/systemd/nspawn/nixos.nspawn
3538
```
3639

3740
The system configuration in `/etc/nixos/configuration.nix` can be adapted to
38-
your needs.
39-
`nixos-rebuild switch` activates a new configuration.
41+
your needs. `nixos-rebuild switch` activates a new configuration.
4042

4143
If you would like to share mounts between host and container, create port
4244
mappings, etc. please refer to the
4345
[`systemd.nspawn` config file documentation](https://man7.org/linux/man-pages/man5/systemd.nspawn.5.html)
44-
and/or the [archlinux wiki about `systemd-nspawn`](https://wiki.archlinux.org/title/systemd-nspawn)
46+
and/or the
47+
[archlinux wiki about `systemd-nspawn`](https://wiki.archlinux.org/title/systemd-nspawn)
4548

4649
## Why not Docker images?
4750

4851
Docker puts the file system of any Linux distro around a single process, but it
49-
essentially does not run a whole system.
50-
Running NixOS (or any other distro) in `systemd-nspawn` is similar to running a
51-
full VM, but with the same thin namespace isolation as in Docker, which leads to
52-
less overhead.
52+
essentially does not run a whole system. Running NixOS (or any other distro) in
53+
`systemd-nspawn` is similar to running a full VM, but with the same thin
54+
namespace isolation as in Docker, which leads to less overhead.
5355

5456
Changes that you do to your nspawn container remain persistent by default.

0 commit comments

Comments
 (0)