diff --git a/.forgejo/workflows/nix.yaml b/.forgejo/workflows/nix.yaml new file mode 100644 index 0000000..26ae98a --- /dev/null +++ b/.forgejo/workflows/nix.yaml @@ -0,0 +1,97 @@ +name: "Nix build" +on: + pull_request: + push: + branches: + - main +jobs: + build-docker: + runs-on: debian-latest + steps: + - uses: actions/checkout@v3 + + - name: "Cache Nix store" + uses: actions/cache@v3.0.8 + id: nix-cache + with: + path: /nix + key: "tclip-cache-v1" + + - name: Install Nix + uses: https://github.com/cachix/install-nix-action@v22 + with: + extra_nix_config: "experimental-features = nix-command flakes" + nix_path: nixpkgs=channel:nixos-23.05 + + - name: "Basic CLI and web build" + run: | + nix build .#tclip .#web + + - name: "Docker image build" + run: | + nix build .#docker + + - name: Push image with Skopeo + run: | + nix-env -i skopeo -f '' + wget https://raw.githubusercontent.com/containers/skopeo/main/default-policy.json && mkdir /etc/containers && mv default-policy.json /etc/containers/policy.json + skopeo login --username arch --password $REGISTRY_TOKEN git.gmem.ca + skopeo copy docker-archive:result docker://git.gmem.ca/arch/tclip:latest + env: + REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} + + - name: "Portable service build" + run: | + nix build .#portable-service + mkdir -p var + cp ./result/*.raw ./var + - uses: actions/upload-artifact@v3 + with: + name: portable-service + path: ./var/*.raw + + build-docker-arm: + runs-on: debian-latest-arm + steps: + - uses: actions/checkout@v3 + + - name: "Cache Nix store" + uses: actions/cache@v3.0.8 + id: nix-cache + with: + path: /nix + key: "tclip-cache-v1" + + - name: Install Nix + uses: https://github.com/cachix/install-nix-action@v22 + with: + extra_nix_config: "experimental-features = nix-command flakes" + nix_path: nixpkgs=channel:nixos-23.05 + + - name: "Basic CLI and web build" + run: | + nix build .#tclip .#web + + - name: "Docker image build" + run: | + nix build .#docker + + - name: Push image with Skopeo + run: | + nix-env -i skopeo -f '' + wget https://raw.githubusercontent.com/containers/skopeo/main/default-policy.json && mkdir /etc/containers && mv default-policy.json /etc/containers/policy.json + skopeo login --username arch --password $REGISTRY_TOKEN git.gmem.ca + skopeo copy docker-archive:result docker://git.gmem.ca/arch/tclip:arm + env: + REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} + + - name: "Portable service build" + run: | + nix build .#portable-service + mkdir -p var + cp ./result/*.raw ./var + - uses: actions/upload-artifact@v3 + with: + name: portable-service + path: ./var/*.raw +