Fix panic from wrong type conversion in ng rules #819
Workflow file for this run
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: "azqr-build" | |
on: | |
workflow_dispatch: | |
push: | |
paths-ignore: | |
- docs/** | |
branches: | |
- main | |
- release-* | |
- feature-* | |
tags: | |
- v* | |
pull_request: | |
paths-ignore: | |
- docs/** | |
branches: | |
- main | |
- release-* | |
permissions: read-all | |
jobs: | |
build: | |
name: Build ${{ matrix.target_os }}_${{ matrix.target_arch }} binaries | |
runs-on: ${{ matrix.os }} | |
permissions: | |
contents: read | |
packages: write | |
env: | |
GOVER: '1.23' | |
GOLANGCILINT_VER: v1.61 | |
GOOS: ${{ matrix.target_os }} | |
GOARCH: ${{ matrix.target_arch }} | |
GOPROXY: https://proxy.golang.org | |
ARCHIVE_OUTDIR: dist/archives | |
PROJECT_NAME: azqr | |
strategy: | |
matrix: | |
os: [ubuntu-latest, windows-latest, macos-latest] | |
target_arch: [amd64, arm, arm64] | |
include: | |
- os: ubuntu-latest | |
target_os: linux | |
filename: azqr | |
- os: windows-latest | |
target_os: windows | |
filename: azqr.exe | |
- os: macOS-latest | |
target_os: darwin | |
filename: azqr | |
exclude: | |
- os: windows-latest | |
target_arch: arm | |
- os: windows-latest | |
target_arch: arm64 | |
- os: macOS-latest | |
target_arch: arm | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
submodules: 'recursive' | |
- name: Set up Go ${{ env.GOVER }} | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ${{ env.GOVER }} | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
- name: Setup MinVer | |
run: | | |
dotnet tool install --global minver-cli --version 4.3.0 | |
- name: golangci-lint | |
if: matrix.target_os == 'linux' && matrix.target_arch == 'amd64' | |
uses: golangci/golangci-lint-action@v3 | |
with: | |
version: ${{ env.GOLANGCILINT_VER }} | |
skip-pkg-cache: true | |
args: --timeout 3m --verbose | |
- name: Run go mod tidy & check diff | |
if: matrix.target_os == 'linux' && matrix.target_arch == 'amd64' | |
run: | | |
go mod tidy | |
git diff --exit-code ./go.mod | |
git diff --exit-code ./go.sum | |
- name: Run Go vet | |
if: matrix.target_os == 'linux' && matrix.target_arch == 'amd64' | |
run: | | |
go vet ./... | |
- name: Run Tests | |
if: matrix.target_os == 'linux' && matrix.target_arch == 'amd64' | |
env: | |
COVERAGE_OPTS: "-coverprofile=coverage.txt -covermode=atomic" | |
run: | | |
go install gotest.tools/gotestsum@latest | |
CGO_ENABLED=0 gotestsum --jsonfile ./test_report_unit.json --format standard-quiet -- ./... $COVERAGE_OPTS --tags=unit | |
go test ./... | |
- name: Codecov | |
if: matrix.target_os == 'linux' && matrix.target_arch == 'amd64' | |
uses: codecov/codecov-action@v3 | |
- name: Calculate Version | |
run: | | |
echo "MINVERVERSIONOVERRIDE=$($HOME/.dotnet/tools/minver -t v. -m 0.1 -p preview.0)" >> $GITHUB_ENV | |
if: matrix.os != 'windows-latest' | |
- name: Calculate Version Windows | |
run: | | |
echo "MINVERVERSIONOVERRIDE=$(minver -t v. -m 0.1 -p preview.0)" >> $env:GITHUB_ENV | |
if: matrix.os == 'windows-latest' | |
- name: output folder variable linux & mac | |
if: matrix.target_os != 'windows' | |
run: | | |
echo AZQR_OUTPUT_FOLDER=${{ env.ARCHIVE_OUTDIR }}/${{ matrix.target_os }}/${{ matrix.target_arch }} >> $GITHUB_ENV | |
- name: output folder variable windows | |
if: matrix.target_os == 'windows' | |
run: | | |
echo AZQR_OUTPUT_FOLDER=${{ env.ARCHIVE_OUTDIR }}/${{ matrix.target_os }}/${{ matrix.target_arch }} >> $env:GITHUB_ENV | |
- name: Create output folder | |
run: | | |
mkdir -p ${{ env.AZQR_OUTPUT_FOLDER }} | |
- name: Run build and archive non windows binaries | |
if: matrix.target_os != 'windows' | |
run: | | |
CGO_ENABLED=0 GOOS=${{ matrix.target_os }} GOARCH=${{ matrix.target_arch }} go build -ldflags "-s -w -X 'github.com/Azure/azqr/cmd/azqr.version=${{ env.MINVERVERSIONOVERRIDE }}'" -o ${{ env.AZQR_OUTPUT_FOLDER }}/${{ matrix.filename }} ./cmd/main.go | |
- name: Run build and archive windows binaries | |
if: matrix.target_os == 'windows' | |
run: | | |
go build -ldflags "-s -w -X 'github.com/Azure/azqr/cmd/azqr.version=${{ env.MINVERVERSIONOVERRIDE }}'" -o ${{ env.AZQR_OUTPUT_FOLDER }}/${{ matrix.filename }} ./cmd/main.go | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: ${{ env.PROJECT_NAME }}-${{ matrix.os }}-${{ matrix.target_arch }} | |
path: ${{ env.AZQR_OUTPUT_FOLDER }}/${{ matrix.filename }} | |
release: | |
name: Create Release | |
needs: build | |
if: github.event_name != 'pull_request' && startswith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
outputs: | |
upload_url: ${{ steps.create_release.outputs.upload_url }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Get changes since lastest tag | |
run: | | |
echo "AZQR_CHANGE_LOG=$(git log $(git describe --tags --abbrev=0)..HEAD --oneline)" >> $GITHUB_ENV | |
- name: release | |
uses: actions/create-release@v1 | |
id: create_release | |
with: | |
tag_name: ${{ github.ref }} | |
release_name: ${{ env.MINVERVERSIONOVERRIDE }} | |
body: ${{ env.AZQR_CHANGE_LOG }} | |
draft: false | |
prerelease: ${{ contains(env.MINVERVERSIONOVERRIDE, 'preview') }} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
publish: | |
name: Publish binaries | |
needs: release | |
permissions: | |
contents: write | |
strategy: | |
matrix: | |
os: [ubuntu-latest, macos-latest, windows-latest] | |
target_arch: [amd64, arm, arm64] | |
exclude: | |
- os: windows-latest | |
target_arch: arm | |
- os: windows-latest | |
target_arch: arm64 | |
- os: macOS-latest | |
target_arch: arm | |
if: github.event_name != 'pull_request' && startswith(github.ref, 'refs/tags/v') | |
env: | |
ARTIFACT_DIR: ${{ github.workspace }}/release | |
PROJECT_NAME: azqr | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code | |
uses: actions/checkout@v3 | |
- name: Artifact Name linux & mac | |
if: matrix.target_os != 'windows' | |
run: | | |
echo AZQR_ARTIFACT_NAME=${{ env.PROJECT_NAME }}-${{ matrix.os }}-${{ matrix.target_arch }} >> $GITHUB_ENV | |
- name: Artifact Name windows | |
if: matrix.target_os == 'windows' | |
run: | | |
echo AZQR_ARTIFACT_NAME=${{ env.PROJECT_NAME }}-${{ matrix.os }}-${{ matrix.target_arch }} >> $env:GITHUB_ENV | |
- name: download artifacts - ${{ env.AZQR_ARTIFACT_NAME }} | |
uses: actions/[email protected] | |
with: | |
name: ${{ env.AZQR_ARTIFACT_NAME }} | |
path: ${{ env.ARTIFACT_DIR }}/${{ env.AZQR_ARTIFACT_NAME }}/ | |
- name: Create sha256 Checksums for linux and mac | |
if: matrix.os != 'windows-latest' | |
run: | | |
sha256sum ${{ env.ARTIFACT_DIR }}/${{ env.AZQR_ARTIFACT_NAME }}/azqr > ${{ env.ARTIFACT_DIR }}/${{ env.AZQR_ARTIFACT_NAME }}.sha256 | |
- name: Create sha256 Checksums for windows | |
if: matrix.os == 'windows-latest' | |
run: | | |
sha256sum ${{ env.ARTIFACT_DIR }}/${{ env.AZQR_ARTIFACT_NAME }}/azqr.exe > ${{ env.ARTIFACT_DIR }}/${{ env.AZQR_ARTIFACT_NAME }}.exe.sha256 | |
- name: upload linux & mac artifacts | |
if: matrix.os != 'windows-latest' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ needs.release.outputs.upload_url }} | |
asset_path: ${{ env.ARTIFACT_DIR }}/${{ env.AZQR_ARTIFACT_NAME }}/azqr | |
asset_name: ${{ env.AZQR_ARTIFACT_NAME }} | |
asset_content_type: application/octet-stream | |
- name: upload linux & mac sha256 | |
if: matrix.os != 'windows-latest' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ needs.release.outputs.upload_url }} | |
asset_path: ${{ env.ARTIFACT_DIR }}/${{ env.AZQR_ARTIFACT_NAME }}.sha256 | |
asset_name: ${{ env.AZQR_ARTIFACT_NAME }}.sha256 | |
asset_content_type: application/octet-stream | |
- name: upload windows artifact | |
if: matrix.os == 'windows-latest' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ needs.release.outputs.upload_url }} | |
asset_path: ${{ env.ARTIFACT_DIR }}/${{ env.AZQR_ARTIFACT_NAME }}/azqr.exe | |
asset_name: ${{ env.AZQR_ARTIFACT_NAME }}.exe | |
asset_content_type: application/octet-stream | |
- name: upload windows sha256 | |
if: matrix.os == 'windows-latest' | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
with: | |
upload_url: ${{ needs.release.outputs.upload_url }} | |
asset_path: ${{ env.ARTIFACT_DIR }}/${{ env.AZQR_ARTIFACT_NAME }}.exe.sha256 | |
asset_name: ${{ env.AZQR_ARTIFACT_NAME }}.exe.sha256 | |
asset_content_type: application/octet-stream | |
bump-winget: | |
name: bump-winget | |
needs: publish | |
permissions: | |
contents: write | |
if: github.event_name != 'pull_request' && startswith(github.ref, 'refs/tags/v') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Setup .NET Core | |
uses: actions/setup-dotnet@v3 | |
with: | |
dotnet-version: 6.0.x | |
- name: Setup MinVer | |
run: | | |
dotnet tool install --global minver-cli --version 4.3.0 | |
- name: Calculate Version | |
run: | | |
echo "MINVERVERSIONOVERRIDE=$($HOME/.dotnet/tools/minver -t v. -m 0.1 -p preview.0)" >> $GITHUB_ENV | |
- name: Trigger Bump Winget | |
uses: peter-evans/repository-dispatch@v2 | |
with: | |
event-type: bump-winget | |
client-payload: '{"version": "${{ env.MINVERVERSIONOVERRIDE }}"}' |