Merge pull request #83 from FlorisFeddema/renovate/github.com-go-co-o… #113
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: 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@b4ffde65f46336ab88eb53be808477a3936bae11 # 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@b4ffde65f46336ab88eb53be808477a3936bae11 # 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@b4ffde65f46336ab88eb53be808477a3936bae11 # 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 }}" |