fix: fixed bugs #4
Workflow file for this run
This file contains hidden or 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: | |
| tags: | |
| - '*' | |
| permissions: | |
| contents: write | |
| packages: write | |
| jobs: | |
| test: | |
| name: Lint and Test | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Go Environment | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Install golangci-lint | |
| uses: golangci/golangci-lint-action@v4 | |
| with: | |
| version: latest | |
| - name: Run linter | |
| run: make lint | |
| - name: Run tests | |
| run: make test | |
| build-binaries: | |
| name: Build Binaries | |
| runs-on: ubuntu-latest | |
| needs: test | |
| strategy: | |
| matrix: | |
| os: [linux, windows, darwin] | |
| arch: [amd64, arm64] | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Setup Go Environment | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version-file: 'go.mod' | |
| - name: Set up Go version | |
| id: go_version | |
| run: echo "GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')" >> $GITHUB_ENV | |
| - name: Extract tag name | |
| id: extract_tag | |
| run: echo "VERSION=${{ github.ref_name }}" >> $GITHUB_ENV | |
| - name: Build binary | |
| run: | | |
| mkdir -p dist | |
| OUTPUT_FILE="dist/envgen-${{ matrix.os }}-${{ matrix.arch }}" | |
| if [ "${{ matrix.os }}" = "windows" ]; then | |
| OUTPUT_FILE="$OUTPUT_FILE.exe" | |
| fi | |
| GOOS=${{ matrix.os }} GOARCH=${{ matrix.arch }} VERSION=${{ env.VERSION }} make build | |
| mv bin/envgen "$OUTPUT_FILE" | |
| echo "Generated binary: $OUTPUT_FILE" | |
| - name: Upload binary | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: envgen-${{ matrix.os }}-${{ matrix.arch }} | |
| path: dist/envgen-${{ matrix.os }}-${{ matrix.arch }}* | |
| create-release: | |
| name: Create Release | |
| runs-on: ubuntu-latest | |
| needs: build-binaries | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Download binaries | |
| uses: actions/download-artifact@v4 | |
| with: | |
| path: dist | |
| pattern: envgen-* | |
| merge-multiple: true | |
| - name: Create Release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| files: | | |
| dist/* | |
| generate_release_notes: true | |
| build-docker: | |
| name: Build And Push Docker Image | |
| runs-on: ubuntu-latest | |
| needs: test | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Go version | |
| id: go_version | |
| run: echo "GO_VERSION=$(grep '^go ' go.mod | awk '{print $2}')" >> $GITHUB_ENV | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to the Container registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ github.repository }} | |
| tags: | | |
| type=semver,pattern={{version}} | |
| type=semver,pattern={{major}}.{{minor}} | |
| type=semver,pattern={{major}} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| GO_VERSION=${{ env.GO_VERSION }} | |
| VERSION=${{ github.ref_name }} |