github.com/hrntknr/ntf@v1.0.2-0.20220725163249-d52a7861d93d/.github/workflows/build.yml (about)

     1  on:
     2    push:
     3      tags:
     4        - v*
     5  jobs:
     6    build:
     7      strategy:
     8        matrix:
     9          target:
    10            - x86_64-unknown-linux-gnu
    11            - x86_64-apple-darwin
    12          include:
    13            - target: x86_64-unknown-linux-gnu
    14              os: ubuntu-latest
    15            - target: x86_64-apple-darwin
    16              os: macos-latest
    17      runs-on: ${{ matrix.os }}
    18      steps:
    19        - uses: actions/setup-go@v2
    20          with:
    21            go-version: ^1.18
    22  
    23        - uses: actions/checkout@v2
    24  
    25        - run: go build -ldflags "-s -w"
    26  
    27        - uses: actions/upload-artifact@v1
    28          with:
    29            name: ntf-${{ matrix.target }}
    30            path: ntf
    31  
    32        - uses: actions/cache@v2
    33          with:
    34            path: ~/go/pkg/mod
    35            key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
    36            restore-keys: |
    37              ${{ runner.os }}-go-
    38  
    39    create-release:
    40      needs:
    41        - build
    42      runs-on: ubuntu-latest
    43      steps:
    44        - id: create-release
    45          uses: actions/create-release@v1
    46          env:
    47            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    48          with:
    49            tag_name: ${{ github.ref }}
    50            release_name: ${{ github.ref }}
    51            draft: false
    52            prerelease: true
    53        - run: |
    54            echo '${{ steps.create-release.outputs.upload_url }}' > release_upload_url.txt
    55        - uses: actions/upload-artifact@v1
    56          with:
    57            name: create-release
    58            path: release_upload_url.txt
    59  
    60    upload-release:
    61      strategy:
    62        matrix:
    63          target:
    64            - x86_64-unknown-linux-gnu
    65            - x86_64-apple-darwin
    66      needs:
    67        - create-release
    68      runs-on: ubuntu-latest
    69      steps:
    70        - uses: actions/download-artifact@v1
    71          with:
    72            name: create-release
    73        - id: upload-url
    74          run: |
    75            echo "::set-output name=url::$(cat create-release/release_upload_url.txt)"
    76        - uses: actions/download-artifact@v1
    77          with:
    78            name: ntf-${{ matrix.target }}
    79        - uses: actions/upload-release-asset@v1
    80          env:
    81            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    82          with:
    83            upload_url: ${{ steps.upload-url.outputs.url }}
    84            asset_path: ./ntf-${{ matrix.target }}/ntf
    85            asset_name: ntf-${{ matrix.target }}
    86            asset_content_type: application/octet-stream