Skip to content

Commit

Permalink
Local nix files, workflows, and more.
Browse files Browse the repository at this point in the history
  • Loading branch information
Alina Shumann committed Nov 11, 2024
1 parent 4769bd1 commit ba9f54d
Show file tree
Hide file tree
Showing 10 changed files with 596 additions and 95 deletions.
10 changes: 6 additions & 4 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
config.yml
!.circleci/config.yml
test
dist
# Ignore all files
*
# Except go files
!go.mod
!go.sum
!**/*.go
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
26 changes: 26 additions & 0 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": [
"config:recommended"
],
"nix": {
"enabled": true
},
"lockFileMaintenance": {
"enabled": true,
"automerge": true,
"schedule": [
"before 4am"
]
},
"packageRules": [
{
"matchUpdateTypes": [
"minor",
"patch"
],
"matchCurrentVersion": "!/^0/",
"automerge": true
}
]
}
58 changes: 58 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Build Docker Images

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

on:
push:
branches:
- main
tags:
- 'v*'

workflow_dispatch:

jobs:
push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
defaults:
run:
working-directory: './Store'
steps:
- name: 'Checkout GitHub Action'
uses: actions/checkout@v4
- name: Log in to Docker Hub
uses: docker/login-action@3d58c274f17dffee475a5520cbe67f0a882c4dbb
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Log in to the Container registry
uses: docker/login-action@3d58c274f17dffee475a5520cbe67f0a882c4dbb
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@8e5442c4ef9f78752691e2d8f8d19755c6f78e81
with:
images: |
screepers/${{ env.IMAGE_NAME }}
ghcr.io/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
uses: docker/build-push-action@94d76d3bc1409736cb5dc1ada9502bec3a72973c
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Generate artifact attestation
uses: actions/attest-build-provenance@v1
with:
subject-name: ghcr.io/${{ env.IMAGE_NAME}}
subject-digest: ${{ steps.push.outputs.digest }}
push-to-registry: true
73 changes: 73 additions & 0 deletions .github/workflows/go.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Build and Release

on: [push]

env:
go-version: 1.22.x

jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Go ${{ env.go-version }}
uses: actions/setup-go@v5
with:
go-version: '${{ env.go-version }}'
- name: Install dependencies
run: go get .
- name: Vet
run: go vet ./...
- name: Test
run: go test ./...
build:
needs: test
runs-on: ubuntu-latest
strategy:
matrix:
os: [linux, darwin, windows]
arch: [amd64, arm, arm64]
eclude:
- os: windows
arch: arm
- os: darwin
arch: arm
- os: darwin
arch: arm64
steps:
- uses: actions/checkout@v4
- name: Setup Go ${{ env.go-version }}
uses: actions/setup-go@v5
with:
go-version: '${{ env.go-version }}'
- name: Install dependencies
run: go get .
- name: Build
run: GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} go build -o ./bin/screeps-launcher_${{ matrix.os }}_${{ matrix.arch }} ./cmd/screeps-launcher
- name: Upload binary
uses: actions/upload-artifact@v4
with:
name: screeps-launcher
path: ./bin/
release:
if: startsWith(github.ref, 'refs/tags/')
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@master
with:
name: screeps-launcher
path: ./bin
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: bin/*
- name: Upload binaries
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./bin
asset_name: screeps-launcher_${{ matrix.os }}_${{ matrix.arch }}
asset_content_type: application/octet-stream
130 changes: 130 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
description = "screeps-launcher flake";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
gomod2nix.url = "github:nix-community/gomod2nix";
};
outputs = { self, nixpkgs, flake-utils, gomod2nix }:
(flake-utils.lib.eachDefaultSystem
(system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ gomod2nix.overlays.default ];
};
screeps-launcher = pkgs.buildGoApplication {
pname = "screeps-launcher";
version = "1.16.0";
src = ./.;
modules = ./gomod2nix.toml;
subPackages = [ "cmd/screeps-launcher" ];
# force 1.22, 1.23 is currently broken due to modules.txt not being generated
go = pkgs.go_1_22;
};
in
{
packages = {
default = screeps-launcher;
# Disable for now, this needs to be considered due to needing build
# dependencies for screeps
# docker = pkgs.dockerTools.buildLayeredImage {
# name = "screeps-launcher";
# config = {
# Cmd = [ "${screeps-launcher}/bin/screeps-launcher" ];
# };
# };
};
devShells.default = pkgs.mkShell {
packages = [
(pkgs.mkGoEnv { pwd = ./.; })
pkgs.gomod2nix
];
};
})
);
}
Loading

0 comments on commit ba9f54d

Please sign in to comment.