github.com/bytom/bytom@v1.1.2-0.20221014091027-bbcba3df6075/.github/workflows/release.yml (about) 1 name: Release 2 3 on: 4 push: 5 # Publish `v1.2.3` tags as releases. 6 tags: 7 - v* 8 9 jobs: 10 build: 11 name: Build Release 12 strategy: 13 matrix: 14 go-version: [1.16.x] 15 os: [ubuntu-18.04, macos-11, windows-2019] 16 runs-on: ${{ matrix.os }} 17 steps: 18 - name: Install Go 19 uses: actions/setup-go@v2 20 with: 21 go-version: ${{ matrix.go-version }} 22 23 - name: Checkout Code 24 uses: actions/checkout@v2 25 26 - uses: actions/cache@v2 27 with: 28 # In order: 29 # * Module download cache 30 # * Build cache (Linux) 31 # * Build cache (Mac) 32 # * Build cache (Windows) 33 path: | 34 ~/go/pkg/mod 35 ~/.cache/go-build 36 ~/Library/Caches/go-build 37 %LocalAppData%\go-build 38 key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} 39 restore-keys: | 40 ${{ runner.os }}-go- 41 # ============================== 42 # Linux/Macos/Windows Build 43 # ============================== 44 45 - name: Build Binary for ${{matrix.os}} 46 run: make bytomd 47 48 # ============================== 49 # Upload artifacts 50 # ============================== 51 52 - name: Upload Linux Build 53 uses: actions/upload-artifact@v2 54 if: matrix.os == 'ubuntu-18.04' 55 with: 56 name: linux 57 path: ./cmd/bytomd/bytomd 58 59 - name: Upload MacOS Build 60 uses: actions/upload-artifact@v2 61 if: matrix.os == 'macos-11' 62 with: 63 name: macos 64 path: ./cmd/bytomd/bytomd 65 66 - name: Upload Windows Build 67 uses: actions/upload-artifact@v2 68 if: matrix.os == 'windows-2019' 69 with: 70 name: windows 71 path: ./cmd/bytomd/bytomd 72 73 release: 74 name: Release 75 needs: build 76 runs-on: ubuntu-18.04 77 steps: 78 - name: Set Env 79 run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV 80 81 - name: Checkout Code 82 uses: actions/checkout@v2 83 84 # ============================== 85 # Download artifacts 86 # ============================== 87 88 - name: Download Artifacts 89 uses: actions/download-artifact@v2 90 with: 91 name: linux 92 path: ./linux 93 94 - name: Download Artifacts 95 uses: actions/download-artifact@v2 96 with: 97 name: macos 98 path: ./macos 99 100 - name: Download Artifacts 101 uses: actions/download-artifact@v2 102 with: 103 name: windows 104 path: ./windows 105 106 # ============================== 107 # Create release 108 # ============================== 109 - name: Generate Change Log 110 id: changelog 111 run: | 112 chmod 755 ./.github/generate_change_log.sh 113 CHANGELOG=$(./.github/generate_change_log.sh ${{ env.RELEASE_VERSION}}) 114 echo "CHANGELOG<<EOF" >> $GITHUB_ENV 115 echo "$CHANGELOG" >> $GITHUB_ENV 116 echo "EOF" >> $GITHUB_ENV 117 - name: Create Release 118 id: create_release 119 uses: actions/create-release@latest 120 env: 121 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token 122 with: 123 tag_name: ${{ github.ref }} 124 release_name: ${{ github.ref }} 125 body: | 126 ${{ env.CHANGELOG }} 127 draft: false 128 prerelease: false 129 130 # Check downloaded files 131 - run: ls 132 133 - name: Upload Release Asset - Linux 134 uses: actions/upload-release-asset@v1 135 env: 136 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 137 with: 138 upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 139 asset_path: ./linux/bytomd 140 asset_name: bytomd_linux 141 asset_content_type: application/octet-stream 142 143 - name: Upload Release Asset - MacOS 144 uses: actions/upload-release-asset@v1 145 env: 146 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 147 with: 148 upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 149 asset_path: ./macos/bytomd 150 asset_name: bytomd_mac 151 asset_content_type: application/octet-stream 152 153 - name: Upload Release Asset - Windows 154 uses: actions/upload-release-asset@v1 155 env: 156 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 157 with: 158 upload_url: ${{ steps.create_release.outputs.upload_url }} # This pulls from the CREATE RELEASE step above, referencing it's ID to get its outputs object, which include a `upload_url`. See this blog post for more info: https://jasonet.co/posts/new-features-of-github-actions/#passing-data-to-future-steps 159 asset_path: ./windows/bytomd 160 asset_name: bytomd_windows.exe 161 asset_content_type: application/octet-stream