mirror of
https://github.com/plazonic/nvidia_gpu_prometheus_exporter.git
synced 2026-11-13 09:53:56 +01:00
84 lines
2.3 KiB
YAML
84 lines
2.3 KiB
YAML
name: Build and Release
|
|
|
|
env:
|
|
VERSION: "v0.2.3"
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*' # Triggers on any tag starting with 'v'
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
arch: ${{ steps.get_arch.outputs.arch }}
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v6
|
|
|
|
- name: Set up Go
|
|
uses: actions/setup-go@v5
|
|
with:
|
|
go-version: '1.21'
|
|
|
|
- name: Get architecture
|
|
id: get_arch
|
|
run: echo "::set-output name=arch::$(uname -m)"
|
|
|
|
- name: Build
|
|
run: go build -ldflags="-X main.version=${{ github.ref_name }}" -o nvml_exporter
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: nvml_exporter-${{ github.ref_name }}-${{ 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@v6
|
|
|
|
- name: Download artifact
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
name: nvml_exporter-${{ github.ref_name }}-${{ needs.build.outputs.arch }}
|
|
|
|
- name: Make artifact executable
|
|
run: chmod +x nvml_exporter
|
|
|
|
- name: Rename executable
|
|
run: mv nvml_exporter nvml_exporter-${{ github.ref_name }}-${{ needs.build.outputs.arch }}
|
|
|
|
- name: Create tar archive
|
|
run: tar -czvf nvml_exporter-${{ github.ref_name }}-${{ needs.build.outputs.arch }}.tar.gz nvml_exporter-${{ github.ref_name }}-${{ needs.build.outputs.arch }}
|
|
|
|
- name: Create Release
|
|
id: create_release
|
|
uses: actions/create-release@v1
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
with:
|
|
tag_name: ${{ github.ref_name }}
|
|
release_name: Release ${{ github.ref_name }}
|
|
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-${{ github.ref_name }}-${{ needs.build.outputs.arch }}.tar.gz
|
|
asset_name: nvml_exporter-${{ github.ref_name }}-${{ needs.build.outputs.arch }}.tar.gz
|
|
asset_content_type: application/octet-stream
|