github.com/tetratelabs/wazero@v1.7.1/.github/workflows/release.yaml (about)

     1  name: Release CLI
     2  on:
     3    pull_request:
     4      branches: [main]
     5      paths-ignore:  # ignore docs as they are built with Netlify.
     6        - '**/*.md'
     7        - 'site/**'
     8        - 'netlify.toml'
     9    push:
    10      branches: [main]
    11      tags: 'v[0-9]+.[0-9]+.[0-9]+**'  # Ex. v0.2.0 v0.2.1-rc2
    12  
    13  env: # Update this prior to requiring a higher minor version in go.mod
    14    GO_VERSION: "1.22"
    15  
    16  defaults:
    17    run:  # use bash for all operating systems unless overridden
    18      shell: bash
    19  
    20  concurrency:
    21    # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#example-using-concurrency-to-cancel-any-in-progress-job-or-run
    22    group: ${{ github.ref }}-${{ github.workflow }}-${{ github.actor }}
    23    cancel-in-progress: true
    24  
    25  jobs:
    26    pre_release:
    27      name: Pre-release build
    28      # This only runs on Windows so that we can simplify the installation of necessary toolchain to build artifacts.
    29      runs-on: windows-2022
    30      # This allows us to test in the following job regardless of the event (tag or not).
    31      outputs:
    32        VERSION: ${{ steps.output-version.outputs.VERSION }}
    33      steps:
    34        - uses: actions/checkout@v3
    35  
    36        - uses: actions/setup-go@v4
    37          with:
    38            cache: false
    39            go-version: ${{ env.GO_VERSION }}
    40  
    41        - uses: actions/cache@v3
    42          with:
    43            path: |
    44              ~/go/pkg/mod
    45              ~/go/bin
    46            key: pre-release-check-${{ runner.os }}-go-${{ matrix.go-version }}-${{ hashFiles('**/go.sum', 'Makefile') }}
    47  
    48        # windows-2022 is missing osslsigncode (no issue, yet)
    49        - name: "Install osslsigncode, infozip; setup wix"
    50          run: |
    51            # Find "C:\Program Files (x86)\WiX Toolset <version>\"
    52            WIXDIR=`ls '/c/Program Files (x86)'|grep WiX`
    53            WIXBIN="C:\\Program Files (x86)\\$WIXDIR\\bin"
    54            echo WIXBIN=$WIXBIN
    55            echo $WIXBIN >> $GITHUB_PATH
    56            choco install osslsigncode -y
    57            choco install zip -y
    58  
    59        - name: Download Windows code signing certificate
    60          env:
    61            WINDOWS_CODESIGN_P12_BASE64: ${{ secrets.WINDOWS_CODESIGN_P12_BASE64 }}
    62          run: | # On the fork PRs, our org secret is not visible.
    63            if [ $WINDOWS_CODESIGN_P12_BASE64 ]; then
    64              echo $WINDOWS_CODESIGN_P12_BASE64 | base64 --decode > windows-certificate.p12
    65              echo "WINDOWS_CODESIGN_P12=windows-certificate.p12" >> $GITHUB_ENV
    66            fi
    67          shell: bash
    68  
    69        - name: Make artifacts (test)
    70          if: github.event_name != 'push' || !contains(github.ref, 'refs/tags/')
    71          run: | # On the fork PRs, our org secret is not visible. We unset the required env so that `make dist` uses default self-signed cert.
    72            if [ $WINDOWS_CODESIGN_P12 ]; then
    73              export WINDOWS_CODESIGN_PASSWORD=${{ secrets.WINDOWS_CODESIGN_PASSWORD }}
    74            fi
    75            VERSION=${{ github.sha }}
    76            make dist VERSION=$VERSION
    77            echo "VERSION=${VERSION}" >> $GITHUB_ENV
    78          shell: bash
    79  
    80        - name: Make artifacts
    81          # Triggers only on tag creation.
    82          if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
    83          env:
    84            WINDOWS_CODESIGN_PASSWORD: ${{ secrets.WINDOWS_CODESIGN_PASSWORD }}
    85          run: | # Note: MSI_VERSION requires . as a separator and admits only numbers, so replace "-[a-z]*" in the tag with ".".
    86            VERSION=${GITHUB_REF#refs/tags/v}
    87            MSI_VERSION=${VERSION//-[a-z]*./.}
    88            make dist VERSION=$VERSION MSI_VERSION=$MSI_VERSION
    89            echo "VERSION=${VERSION}" >> $GITHUB_ENV
    90          shell: bash
    91  
    92        # This allows us to test in the following job regardless of the event (tag or not).
    93        - id: output-version
    94          run: echo "VERSION=${VERSION}" >> "$GITHUB_OUTPUT"
    95          shell: bash
    96  
    97        # In order to share the built artifacts in the subsequent tests, we use cache instead of actions/upload-artifacts.
    98        # The reason is that upload-artifacts are not globally consistent and sometimes pre_release_test won't be able to
    99        # find the artifacts uploaded here. See https://github.com/actions/upload-artifact/issues/21 for more context.
   100        # Downside of this is that, we pressure the cache capacity set per repository. We delete all caches created
   101        # on PRs on close. See .github/workflows/clear_cache.yaml. On main branch, in any way this cache will be deleted
   102        # in 7 days, also this at most a few MB, so this won't be an issue.
   103        - uses: actions/cache@v3
   104          id: cache
   105          with:
   106            # Use share the cache containing archives across OSes.
   107            enableCrossOsArchive: true
   108            # Note: this creates a cache per run.
   109            key: release-artifacts-${{ github.run_id }}
   110            path:
   111              dist/
   112  
   113    # pre_release_test tests the artifacts built by pre_release in the OS dependent way.
   114    pre_release_test:
   115      needs: pre_release
   116      name: Pre-release test (${{ matrix.os }})
   117      runs-on: ${{ matrix.os }}
   118      strategy:
   119        fail-fast: false # don't fail fast as sometimes failures are arch/OS specific
   120        matrix:
   121          os: [ubuntu-22.04, macos-12, windows-2022]
   122  
   123      steps:
   124        - uses: actions/checkout@v3
   125  
   126        - uses: actions/cache@v3
   127          id: cache
   128          with:
   129            # We need this cache to run tests.
   130            fail-on-cache-miss: true
   131            enableCrossOsArchive: true
   132            key: release-artifacts-${{ github.run_id }}
   133            path:
   134              dist/
   135  
   136        - name: Test (linux)
   137           # Check if the version was correctly inserted with VERSION variable
   138          if: runner.os == 'Linux'
   139          run: |
   140            tar xf dist/wazero_${{ needs.pre_release.outputs.VERSION }}_linux_amd64.tar.gz
   141            ./wazero version | grep ${{ needs.pre_release.outputs.VERSION }}
   142  
   143        - name: Test (darwin)
   144          # Check if the version was correctly inserted with VERSION variable
   145          if: runner.os == 'macOS'
   146          run: |
   147            tar xf dist/wazero_${{ needs.pre_release.outputs.VERSION }}_darwin_amd64.tar.gz
   148            ./wazero version | grep ${{ needs.pre_release.outputs.VERSION }}
   149  
   150        # This only checks the installer when built on Windows as it is simpler than switching OS.
   151        # refreshenv is from choco, and lets you reload ENV variables (used here for PATH).
   152        - name: Test Windows Installer
   153          if: runner.os == 'Windows'
   154          run: |
   155            set MSI_FILE="dist\wazero_${{ needs.pre_release.outputs.VERSION }}_windows_amd64.msi"
   156            call packaging\msi\verify_msi.cmd
   157          shell: cmd
   158  
   159    # Triggers only on the tag creation.
   160    release:
   161      if: github.event_name == 'push' && contains(github.ref, 'refs/tags/')
   162      needs: pre_release_test
   163      name: Release
   164      runs-on: ubuntu-22.04
   165      steps:
   166        - uses: actions/checkout@v3
   167          with:  # Ensure release_notes.sh can see prior commits
   168            fetch-depth: 0
   169  
   170        - uses: actions/cache@v3
   171          id: cache
   172          with:
   173            fail-on-cache-miss: true
   174            enableCrossOsArchive: true
   175            key: release-artifacts-${{ github.run_id }}
   176            path:
   177              dist/
   178  
   179        - name: Create draft release
   180          run: |
   181            ls dist
   182            tag="${GITHUB_REF#refs/tags/}"
   183            ./.github/workflows/release_notes.sh ${tag} > release-notes.txt
   184            gh release create ${tag} --draft --notes-file release-notes.txt --title ${GITHUB_REF#refs/tags/} ./dist/*
   185          env:
   186            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}