Parent directory

release.yml

1875 bytes
 1name: Release
 2
 3on:
 4  push:
 5    tags:
 6      - "v*"
 7
 8jobs:
 9  build_release:
10    name: Build logfmt binaries
11    runs-on: ubuntu-latest
12    strategy:
13      matrix:
14        goos: [linux, darwin]
15        goarch: [amd64, arm64]
16    permissions:
17      contents: write
18
19    steps:
20    - name: Checkout code
21      uses: actions/checkout@v4
22
23    - name: Set up Go
24      uses: actions/setup-go@v5
25      with:
26        go-version-file: "go.mod"
27
28    - name: Build
29      env:
30        GOOS: ${{ matrix.goos }}
31        GOARCH: ${{ matrix.goarch }}
32      run: |
33        go build -ldflags="-s -w" -o logfmt-${{ matrix.goos }}-${{ matrix.goarch }}-${{ github.ref_name }}
34
35    - name: Compress with UPX (Linux only)
36      if: matrix.goos == 'linux'
37      uses: crazy-max/ghaction-upx@v3
38      with:
39        files: |
40          ./logfmt-${{ matrix.goos }}-${{ matrix.goarch }}-${{ github.ref_name }}
41        args: --best --lzma
42
43    - name: Upload Build Artifact
44      uses: actions/upload-artifact@v4
45      with:
46        name: logfmt-${{ matrix.goos }}-${{ matrix.goarch }} # Unique name for each artifact
47        path: ./logfmt-${{ matrix.goos }}-${{ matrix.goarch }}-${{ github.ref_name }} # Path to the built executable
48        retention-days: 1
49
50  create_release:
51    name: Create GitHub release from tag version
52    runs-on: ubuntu-latest
53    needs: build_release
54    permissions:
55      contents: write
56
57    steps:
58    - name: Checkout code
59      uses: actions/checkout@v4
60
61    - name: Download all build artifacts
62      uses: actions/download-artifact@v4
63      with:
64        path: release-artifacts
65
66    - name: Create GitHub Release
67      uses: softprops/action-gh-release@v2
68      with:
69        tag_name: ${{ github.ref_name }}
70        name: "Release ${{ github.ref_name }}"
71        body: |
72          Automated release for tag ${{ github.ref_name }}.
73        files: release-artifacts/*/*