Skip to content

Commit

Permalink
update ci file
Browse files Browse the repository at this point in the history
  • Loading branch information
ifurther committed Jan 14, 2024
1 parent 5041b18 commit 710dc5b
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
18 changes: 3 additions & 15 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,9 @@ jobs:
qemu libvirt-daemon-system
- name: Create Vagrant Cloud Box
run: |
curl \
--request POST \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${{ secrets.ATLAS_TOKEN }}" \
https://app.vagrantup.com/api/v2/boxes \
--data '{ "box": { "username": "nixbox", "name": "nixos" } }'
env:
ATLAS_TOKEN: ${{ secrets.ATLAS_TOKEN }}
run: make vagrantcloud-create

- name: Setup `packer`
uses: hashicorp/setup-packer@main
Expand All @@ -50,11 +46,3 @@ jobs:
env:
ATLAS_TOKEN: ${{ secrets.ATLAS_TOKEN }}
run: make VERSION=${GITHUB_REF#refs/heads/nixos-} BUILDER=${{ matrix.BUILDER }} packer-build

- name: Release the Vagrant Cloud box
run: |
curl \
--request PUT \
--header "Authorization: Bearer ${{ secrets.ATLAS_TOKEN }}" \
"https://app.vagrantup.com/api/v2/box/nixbox/nixos/version/${GITHUB_REF#refs/heads/nixos-}/release"
19 changes: 19 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ BUILDER ?= virtualbox-iso.virtualbox
VERSION ?= 23.05
ARCH ?= x86_64
REPO ?= nixbox/nixos
CI_VERSION ?= ${GITHUB_REF#refs/heads/nixos-}
REPO_NAME = $(word 1, $(subst /, ,${REPO}))
BOX_NAME = $(word 2, $(subst /, ,${REPO}))
BUILD_PROVIDER = $(word 2, $(subst ., ,${BUILDER}))

all: help
Expand Down Expand Up @@ -50,11 +53,27 @@ vagrant-push: vagrant-plugin ## Push builded vagrant box
--no-private \
--short-description "NixOS ${VERSION}" \
${REPO}-${VERSION} ${VERSION} ${BUILD_PROVIDER} nixos-${VERSION}-${BUILDER}-${ARCH}.box

vagrantcloud-create: ## Create Vagrant Cloud box
@curl \
--request POST \
--header "Content-Type: application/json" \
--header "Authorization: Bearer ${ATLAS_TOKEN}" \
https://app.vagrantup.com/api/v2/boxes \
--data '{ "box": { "username": "'"${REPO_NAME}"'", "name": "'"${BOX_NAME}"'", "is_private": false } }'

vagrantcloud-release: ## Release Vagrant CLoude box
@curl \
--request PUT \
--header "Authorization: Bearer ${ATLAS_TOKEN}" \
"https://app.vagrantup.com/api/v2/box/${REPO}/version/${CI_VERSION}/release"

packer-build: nixos.pkr.hcl version ##Use packer push to vagrant-cloud
packer init $<
packer build \
-var arch=${ARCH} \
-var builder="${BUILDER}" \
-var cloud_repo=${REPO} \
-var version=${VERSION} \
-var iso_checksum="$(shell curl -sL https://channels.nixos.org/nixos-${VERSION}/latest-nixos-minimal-${ARCH}-linux.iso.sha256 | grep -Eo '^[0-9a-z]{64}')" \
--only=${BUILDER} \
Expand Down
1 change: 1 addition & 0 deletions nixos.pkr.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ build {
access_token = "${var.cloud_token}"
box_tag = "${var.cloud_repo}"
version = "${var.version}"
architecture = "${lookup(var.vagrant_cloud_arch, var.arch, "amd64")}"
}
}
}

0 comments on commit 710dc5b

Please sign in to comment.