github.com/vmware/govmomi@v0.37.1/.github/workflows/govmomi-build.yaml (about)

     1  #  Copyright (c) 2021 VMware, Inc. All Rights Reserved.
     2  #
     3  #  Licensed under the Apache License, Version 2.0 (the "License");
     4  #  you may not use this file except in compliance with the License.
     5  #  You may obtain a copy of the License at
     6  #
     7  #  http://www.apache.org/licenses/LICENSE-2.0
     8  #
     9  #  Unless required by applicable law or agreed to in writing, software
    10  #  distributed under the License is distributed on an "AS IS" BASIS,
    11  #  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  #  See the License for the specific language governing permissions and
    13  #  limitations under the License.
    14  
    15  name: Build
    16  
    17  on:
    18    push:
    19      branches: ["main"]
    20  
    21    pull_request:
    22      branches: ["main"]
    23  
    24    # also run every night
    25    schedule:
    26      - cron: "0 1 * * *"
    27  
    28    workflow_dispatch:
    29  
    30  concurrency:
    31    group: govmomi-build-${{ github.head_ref || github.run_id }}
    32    cancel-in-progress: true
    33  
    34  jobs:
    35    artifacts:
    36      name: Build Snapshot Release (no upload)
    37      runs-on: ubuntu-20.04
    38      timeout-minutes: 15
    39  
    40      steps:
    41        - name: Checkout
    42          uses: actions/checkout@v4
    43          with:
    44            fetch-depth: 0 # for CHANGELOG
    45  
    46        - name: Set up Go
    47          uses: actions/setup-go@v5
    48          with:
    49            go-version: 1.21
    50  
    51        - name: Restore Go cache
    52          uses: actions/cache@v4
    53          with:
    54            path: |
    55              ~/.cache/go-build
    56              ~/go/pkg/mod
    57            key: ${{ runner.os }}-go-1.21-${{ hashFiles('**/go.sum') }}
    58            restore-keys: |
    59              ${{ runner.os }}-go-1.21-
    60  
    61        - name: Create CHANGELOG
    62          env:
    63            IMAGE: quay.io/git-chglog/git-chglog
    64            # https://quay.io/repository/git-chglog/git-chglog from tag v0.14.2
    65            IMAGE_SHA: 998e89dab8dd8284cfff5f8cfb9e9af41fe3fcd4671f2e86a180e453c20959e3
    66          run: |
    67            # use a pseudo tag to only include changes since last release
    68            NEXT_TAG=$(git describe --abbrev=0 --tags)-next
    69            docker run --rm -v $PWD:/workdir ${IMAGE}@sha256:${IMAGE_SHA} --next-tag ${NEXT_TAG} -o RELEASE_CHANGELOG.md --sort semver --tag-filter-pattern '^v[0-9]+' ${NEXT_TAG}
    70  
    71        - name: Archive CHANGELOG
    72          uses: actions/upload-artifact@v4
    73          with:
    74            name: CHANGELOG
    75            path: |
    76              ./RELEASE_CHANGELOG.md
    77            retention-days: 1
    78  
    79        - name: Build Artifacts
    80          uses: goreleaser/goreleaser-action@v5
    81          env:
    82            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    83          with:
    84            version: latest
    85            # snapshot will disable push/release
    86            args: release --clean --snapshot --release-notes RELEASE_CHANGELOG.md
    87  
    88        - name: Verify git clean
    89          shell: bash
    90          run: |
    91            if [[ -z "$(git status --porcelain)" ]]; then
    92              echo "${{ github.repository }} up to date."
    93            else
    94              echo "${{ github.repository }} is dirty."
    95              echo "::error:: $(git status)"
    96              exit 1
    97            fi
    98  
    99        # make artifacts available for inspection
   100        # https://docs.github.com/en/actions/guides/storing-workflow-data-as-artifacts
   101        - name: Archive run artifacts
   102          uses: actions/upload-artifact@v4
   103          with:
   104            name: dist
   105            # upload only some artifacts for introspection to keep storage size small (delete after 1d)
   106            path: |
   107              dist/govc_*x86_64.tar.gz
   108              dist/vcsim_*x86_64.tar.gz
   109              dist/checksums.txt
   110            retention-days: 1