Merge pull request #4 from p-doom/master #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |