Skip to content

Commit

Permalink
Merge pull request #4 from p-doom/master
Browse files Browse the repository at this point in the history
feat: add build and release workflow using github actions
  • Loading branch information
plazonic authored Jan 25, 2025
2 parents 9ad318c + 9d95556 commit 2ee9a44
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 2 deletions.
80 changes: 80 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
name: Build and Release

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-20.04

outputs:
arch: ${{ steps.get_arch.outputs.arch }}

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.21'

- name: Get architecture
id: get_arch
run: echo "::set-output name=arch::$(uname -m)"

- name: Build
run: go build -o nvml_exporter

- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: nvml_exporter-v0.2.0-${{ steps.get_arch.outputs.arch }}
path: nvml_exporter

release:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Download artifact
uses: actions/download-artifact@v3
with:
name: nvml_exporter-v0.2.0-${{ needs.build.outputs.arch }}

- name: Make artifact executable
run: chmod +x nvml_exporter

- name: Rename executable
run: mv nvml_exporter nvml_exporter-v0.2.0-${{ needs.build.outputs.arch }}

- name: Create tar archive
run: tar -czvf nvml_exporter-v0.2.0-${{ needs.build.outputs.arch }}.tar.gz nvml_exporter-v0.2.0-${{ needs.build.outputs.arch }}

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v0.2.0
release_name: Release v0.2.0
draft: false
prerelease: false

- name: Upload Release Asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./nvml_exporter-v0.2.0-${{ needs.build.outputs.arch }}.tar.gz
asset_name: nvml_exporter-v0.2.0-${{ needs.build.outputs.arch }}.tar.gz
asset_content_type: application/octet-stream
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
![GitHub Actions](https://img.shields.io/github/actions/workflow/status/p-doom/nvml_exporter/release.yml?branch=master&label=CI&logo=github)


NVIDIA GPU Prometheus Exporter
------------------------------

Expand Down Expand Up @@ -30,5 +33,5 @@ To make sure that the exporter can access the NVML libraries, either add them
to the search path for shared libraries. Or set `LD_LIBRARY_PATH` to point to
their location.

By default the metrics are exposed on port `9445`. This can be updated using
the `-web.listen-address` flag.
By default the metrics are exposed on `localhost:9445/metrics`. The port can be
modified using the `-web.listen-address` flag.

0 comments on commit 2ee9a44

Please sign in to comment.