1.4.4-5-dev #56
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
# Copyright 2022 | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
name: release | |
# yamllint disable-line rule:truthy | |
on: | |
release: | |
types: [published] | |
workflow_dispatch: | |
env: | |
BIN_NAME: dcld | |
jobs: | |
checks: | |
name: verify release | |
runs-on: ubuntu-latest | |
outputs: | |
included: ${{ steps.release_info.outputs.included }} | |
matrix_os: ${{ steps.release_info.outputs.matrix_os }} | |
upload_url: ${{ steps.release_info.outputs.upload_url }} | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Get current version | |
id: current_version | |
run: | | |
git fetch --all --tags | |
tag="$(git describe --tags --exact-match)" | |
echo "::set-output name=version::${tag#v}" | |
shell: bash | |
- name: Get release info | |
id: release_info | |
run: | | |
release_info="$(curl -s https://api.github.com/repos/${{ github.repository }}/releases \ | |
| jq '.[] | select(.tag_name == "v${{ steps.current_version.outputs.version }}")')" | |
echo "::set-output name=release_info::$release_info" | |
echo "$release_info" | |
asset_bin_url="$(echo "$release_info" \ | |
| jq -r '.assets[] | select(.name | match("^${{ env.BIN_NAME }}$")) | .browser_download_url')" | |
echo "$asset_bin_url" | |
asset_ubuntu_tgz_url="$(echo "$release_info" \ | |
| jq -r '.assets[] | select(.name | match("^${{ env.BIN_NAME }}.ubuntu.tar.gz$")) | .browser_download_url')" | |
echo "$asset_ubuntu_tgz_url" | |
asset_cosmovisor_url="$(echo "$release_info" \ | |
| jq -r '.assets[] | select(.name | match("^cosmovisor$")) | .browser_download_url')" | |
echo "$asset_bin_url" | |
asset_service_url="$(echo "$release_info" \ | |
| jq -r '.assets[] | select(.name | match("^cosmovisor.service$")) | .browser_download_url')" | |
echo "$asset_service_url" | |
asset_deploy_script_url="$(echo "$release_info" \ | |
| jq -r '.assets[] | select(.name | match("^run_dcl_node$")) | .browser_download_url')" | |
echo "$asset_deploy_script_url" | |
asset_macos_tgz_url="$(echo "$release_info" \ | |
| jq -r '.assets[] | select(.name | match("^${{ env.BIN_NAME }}.macos.tar.gz$")) | .browser_download_url')" | |
echo "$asset_macos_tgz_url" | |
upload_url="$(echo "$release_info" | jq -r '.upload_url')" | |
echo "::set-output name=upload_url::$upload_url" | |
echo "$upload_url" | |
# build json string to use later as a job matrix | |
included=() | |
if [[ -z "$asset_bin_url" || -z "$asset_ubuntu_tgz_url" || -z "$asset_cosmovisor_url" || -z "$asset_service_url" || -z "$asset_deploy_script_url" ]]; then | |
# os|bin-url|tgz-url|service-file-url|deploy-script-url|tgz-suffix | |
included+=("ubuntu-20.04|$asset_bin_url|$asset_ubuntu_tgz_url|$asset_cosmovisor_url|$asset_service_url|$asset_deploy_script_url|.ubuntu.tar.gz") | |
fi | |
if [[ -z "$asset_macos_tgz_url" ]]; then | |
# bin, service file and deploy script are not considered for macos job | |
included+=("macos-14|-||-|-|-|.macos.tar.gz") | |
fi | |
matrix_os="$(jq -ncR ' | |
(input | split(" ")) | | |
[ .[] | split("|") | .[0] ] | if .|length > 0 then . else empty end | |
' <<<"${included[*]}" | |
)" | |
echo "::set-output name=matrix_os::$matrix_os" | |
echo "$matrix_os" | |
if [[ -n "$matrix_os" ]]; then | |
included_json="$(jq -ncR ' | |
(input | split(" ")) | | |
[ .[] | split("|") | | |
{"os": .[0], "bin": .[1] | length, "tgz": .[2] | length, "cosmovisor": .[3] | length, "service": .[4] | length, "deploy_script": .[5] | length, "tgz_name_suffix": .[6]} ] | |
' <<<"${included[*]}" | |
)" | |
echo "::set-output name=included::$included_json" | |
echo "$included_json" | |
fi | |
shell: bash | |
- name: check release published | |
if: ${{ !steps.release_info.outputs.release_info }} | |
run: exit 1 | |
release: | |
name: Release | |
needs: checks | |
if: needs.checks.outputs.matrix_os | |
strategy: | |
matrix: | |
os: ${{ fromJson(needs.checks.outputs.matrix_os) }} | |
include: ${{ fromJson(needs.checks.outputs.included) }} | |
runs-on: ${{ matrix.os }} | |
steps: | |
- name: Set up Go 1.x | |
uses: actions/setup-go@v4 | |
with: | |
go-version: ^1.20 | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v2 | |
- uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/go-build | |
~/go/pkg/mod | |
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }} | |
restore-keys: | | |
${{ runner.os }}-go- | |
- name: build application binary | |
if: ${{ !matrix.bin || !matrix.tgz }} | |
run: | | |
make build | |
build/${{ env.BIN_NAME }} version | |
tar czf build/${{ env.BIN_NAME }}${{ matrix.tgz_name_suffix }} -C build ${{ env.BIN_NAME }} | |
shell: bash | |
- name: upload to GitHub (application binary) | |
if: ${{ !matrix.bin }} | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.checks.outputs.upload_url }} | |
asset_path: build/${{ env.BIN_NAME }} | |
asset_name: ${{ env.BIN_NAME }} | |
asset_content_type: application/octet-stream # TODO check for less generic type | |
- name: upload to GitHub (archived application binary) | |
if: ${{ !matrix.tgz }} | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.checks.outputs.upload_url }} | |
asset_path: build/${{ env.BIN_NAME }}${{ matrix.tgz_name_suffix }} | |
asset_name: ${{ env.BIN_NAME }}${{ matrix.tgz_name_suffix }} | |
asset_content_type: application/x-gtar | |
- name: build cosmovisor binary | |
if: ${{ !matrix.cosmovisor }} | |
run: | | |
go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v1.0.0 | |
shell: bash | |
- name: get GOBIN | |
id: get_gobin | |
run: | | |
GOPATH=${GOPATH:-${HOME}/go} | |
GOBIN=${GOBIN:-${GOPATH}/bin} | |
echo "$GOBIN" | |
echo "::set-output name=gobin::$GOBIN" | |
shell: bash | |
- name: upload to GitHub (cosmovisor binary) | |
if: ${{ !matrix.cosmovisor }} | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.checks.outputs.upload_url }} | |
asset_path: ${{ steps.get_gobin.outputs.gobin }}/cosmovisor | |
asset_name: cosmovisor | |
asset_content_type: application/octet-stream # TODO check for less generic type | |
- name: upload to GitHub (service file) | |
if: ${{ !matrix.service }} | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.checks.outputs.upload_url }} | |
asset_path: deployment/cosmovisor.service | |
asset_name: cosmovisor.service | |
asset_content_type: text/plain | |
- name: upload to GitHub (deploy script) | |
if: ${{ !matrix.deploy_script }} | |
uses: actions/upload-release-asset@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
upload_url: ${{ needs.checks.outputs.upload_url }} | |
asset_path: deployment/scripts/run_dcl_node | |
asset_name: run_dcl_node | |
asset_content_type: text/plain |