diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..99f12d2 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,10 @@ +version: 2 +updates: + - package-ecosystem: "gomod" + directory: "/" + schedule: + interval: "monthly" + - package-ecosystem: "github-actions" + directory: "/" + schedule: + interval: "monthly" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..cec5705 --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,34 @@ +name: build +on: [push] +jobs: + build: + strategy: + matrix: + version: [1.24] + os: [ubuntu-latest] + name: Build + runs-on: ${{ matrix.os }} + steps: + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: ${{ matrix.version }} + id: go + + - name: checkout + uses: actions/checkout@v5 + + - name: build + run: go build + + + golangci: + name: lint + runs-on: ubuntu-latest + steps: + - uses: actions/setup-go@v6 + with: + go-version: 1.24 + - uses: actions/checkout@v5 + - name: golangci-lint + uses: golangci/golangci-lint-action@v8 diff --git a/.github/workflows/pushimage.yaml b/.github/workflows/pushimage.yaml new file mode 100644 index 0000000..3961470 --- /dev/null +++ b/.github/workflows/pushimage.yaml @@ -0,0 +1,34 @@ +name: build-push-image + +on: + push: + tags: + - 'v*' + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + packages: write + steps: + - name: Checkout repository + uses: actions/checkout@v5 + + - name: Log in to the Container registry + uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef + with: + registry: https://ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Build and push Docker image + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 + with: + push: true + tags: ghcr.io/tlinden/io-exporter:${{ github.ref_name}} + + - name: Build and push latest Docker image + uses: docker/build-push-action@263435318d21b8e681c14492fe198d362a7d2c83 + with: + push: true + tags: ghcr.io/tlinden/io-exporter:latest diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml new file mode 100644 index 0000000..3fa9c52 --- /dev/null +++ b/.github/workflows/release.yaml @@ -0,0 +1,86 @@ +name: build-release +on: + push: + tags: + - "v*.*.*" + +jobs: + release: + name: Build Release Assets + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v5 + + - name: Set up Go + uses: actions/setup-go@v6 + with: + go-version: 1.24.5 + + - name: Build the executables + run: + - go build + - mv io-exporter io-exporter-amd64-linux-${{ github.ref_name}} + + - name: Upload the binaries + uses: svenstaro/upload-release-action@v2 + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + tag: ${{ github.ref_name }} + file: io-exporter-amd64-linux-${{ github.ref_name}} + file_glob: false + + - name: Build Changelog + id: github_release + uses: mikepenz/release-changelog-builder-action@v5 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + mode: "PR" + configurationJson: | + { + "template": "#{{CHANGELOG}}\n\n**Full Changelog**: #{{RELEASE_DIFF}}", + "pr_template": "- #{{TITLE}} (##{{NUMBER}}) by #{{AUTHOR}}\n#{{BODY}}", + "empty_template": "- no changes", + "categories": [ + { + "title": "## New Features", + "labels": ["add", "feature"] + }, + { + "title": "## Bug Fixes", + "labels": ["fix", "bug", "revert"] + }, + { + "title": "## Documentation Enhancements", + "labels": ["doc"] + }, + { + "title": "## Refactoring Efforts", + "labels": ["refactor"] + }, + { + "title": "## Miscellaneus Changes", + "labels": [] + } + ], + "ignore_labels": [ + "duplicate", "good first issue", "help wanted", "invalid", "question", "wontfix" + ], + "label_extractor": [ + { + "pattern": "(.) (.+)", + "target": "$1" + }, + { + "pattern": "(.) (.+)", + "target": "$1", + "on_property": "title" + } + ] + } + + - name: Create Release + uses: softprops/action-gh-release@v2 + with: + body: ${{steps.github_release.outputs.changelog}} diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3024e96 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,25 @@ +FROM golang:1.24-alpine as builder + +RUN apk update +RUN apk upgrade +RUN apk add --no-cache git make + +RUN git --version + +WORKDIR /work + +COPY go.mod . +COPY . . +RUN go mod download +RUN go build + +FROM alpine:latest +LABEL maintainer="Thomas von Dein " + +WORKDIR /app +COPY --from=builder /work/io-exporter /app/io-exporter + +USER 1001:1001 + +ENTRYPOINT ["/app/io-exporter"] +CMD ["-h"] diff --git a/README.md b/README.md index 9dfa37f..ae94258 100644 --- a/README.md +++ b/README.md @@ -54,6 +54,23 @@ Or, if you have GNU Make installed, just execute: go build ``` +## Docker + +To build: + +```default +docker compose build +``` + +To run locally: + +```default +mkdir t +chmod 1777 t +docker compose run -v ./t:/pvc ioexporter /pvc/blah +``` + + # Report bugs [Please open an issue](https://github.com/TLINDEN/io-exporter/issues). Thanks! diff --git a/docker-compose.yaml b/docker-compose.yaml new file mode 100644 index 0000000..4f8790e --- /dev/null +++ b/docker-compose.yaml @@ -0,0 +1,8 @@ +services: + ioexporter: + container_name: io-exporter + volumes: + - ${PWD}:/pvc + working_dir: /pvc + build: . + image: io-exporter:latest