Skip to content

Merge pull request #88 from FlorisFeddema/renovate/actions-checkout-d… #115

Merge pull request #88 from FlorisFeddema/renovate/actions-checkout-d…

Merge pull request #88 from FlorisFeddema/renovate/actions-checkout-d… #115

Workflow file for this run

name: Release application
on:
push:
branches:
- main
env:
VERSION: 0.1.2
jobs:
build:
name: Build
runs-on: ubuntu-22.04
steps:
- name: Check out code
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 'stable'
- name: Cache dependencies
uses: actions/cache@v4
with:
path: |
~/.cache/go-build
~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Verify dependencies
run: go mod verify
- name: Build application
run: go build .
- name: Run unit tests
run: go test ./... -coverprofile=coverage.out
- name: Run vet
run: go vet .
- name: Install linter
run: go install golang.org/x/lint/golint@latest
- name: Run linter
run: golint ./...
checkVersion:
name: CheckVersion
runs-on: ubuntu-22.04
outputs:
versionCheck: ${{ steps.version.outputs.comparison-result }}
steps:
- name: Check out code
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4
with:
fetch-depth: 0
- name: Read version from Chart.yaml
id: read-version
uses: jbutcher5/read-yaml@main
with:
file: './charts/enphase-envoy-prometheus-exporter/Chart.yaml'
key-path: '["version"]'
- uses: madhead/semver-utils@latest
id: version
with:
version: ${{ env.VERSION }}
compare-to: ${{ steps.read-version.outputs.data }}
release:
name: Release
runs-on: ubuntu-22.04
needs: [ build, checkVersion ]
if: ${{ needs.checkVersion.outputs.versionCheck == '>' }}
steps:
- name: Check out code
uses: actions/checkout@1d96c772d19495a3b5c517cd2bc0cb401ea0529f # v4
with:
fetch-depth: 0
- name: Setup git config
run: |
git config user.name "Floris Feddema"
git config user.email "[email protected]"
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
platforms: linux/amd64,linux/arm64
- name: Login docker registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
tags: |
ghcr.io/florisfeddema/enphase-envoy-prometheus-exporter:latest
ghcr.io/florisfeddema/enphase-envoy-prometheus-exporter:${{ env.VERSION }}
push: true
- name: Update version in Chart.yaml
uses: fjogeleit/yaml-update-action@main
with:
valueFile: 'charts/enphase-envoy-prometheus-exporter/Chart.yaml'
propertyPath: 'version'
value: ${{ env.VERSION }}
message: 'Update Image Version to ${{ env.VERSION }}'
commitChange: true
branch: main
- name: Release chart
uses: helm/[email protected]
with:
charts_dir: charts
env:
CR_TOKEN: "${{ secrets.GITHUB_TOKEN }}"