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