Skip to content

Merge pull request #270 from multiversx/feat/v3 #125

Merge pull request #270 from multiversx/feat/v3

Merge pull request #270 from multiversx/feat/v3 #125

name: Create release
on:
push:
branches:
- main
permissions:
contents: write
pull-requests: write
jobs:
build:
strategy:
matrix:
runs-on: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.runs-on }}
name: Build
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v3
with:
go-version: 1.20.7
id: go
- name: Check out code into the Go module directory
uses: actions/checkout@v3
with:
fetch-depth: "0"
- name: Get dependencies
run: |
go get -v -t -d ./...
if [ -f Gopkg.toml ]; then
curl https://raw.githubusercontent.com/golang/dep/master/install.sh | sh
dep ensure
fi
# https://docs.github.com/en/free-pro-team@latest/actions/reference/workflow-commands-for-github-actions#setting-an-environment-variable
- name: Set environment variables
run: |
APP_VER_SHORT=$(git describe --tags)
GOOS=$(go env GOOS)
GOARCH=$(go env GOARCH)
GOPATH=$(go env GOPATH)
ARCHIVE="multiversx_eth_bridge""$APP_VER_SHORT""_""$GOOS""_""$GOARCH"".tgz"
BUILD_DIR=${GITHUB_WORKSPACE}/build
echo "GOOS=${GOOS}" >> $GITHUB_ENV
echo "GOARCH=${GOARCH}" >> $GITHUB_ENV
echo "ARCHIVE=${ARCHIVE}" >> $GITHUB_ENV
echo "BUILD_DIR=${BUILD_DIR}" >> $GITHUB_ENV
- name: Build
run: |
mkdir -p ${BUILD_DIR}
cd ${GITHUB_WORKSPACE}/cmd/bridge && go build -o "${BUILD_DIR}/" -a -i -ldflags="-X main.appVersion=${APP_VER}"
- name: Package
run: |
cd ${GITHUB_WORKSPACE}
cd ${BUILD_DIR}
tar czvf "${GITHUB_WORKSPACE}/${ARCHIVE}" *
stat ${GITHUB_WORKSPACE}/${ARCHIVE}
- name: Save artifacts
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARCHIVE }}
path: ${{ github.workspace }}/${{ env.ARCHIVE }}
if-no-files-found: error
release:
needs: [build]
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3
# https://docs.github.com/en/free-pro-team@latest/actions/guides/storing-workflow-data-as-artifacts#downloading-or-deleting-artifacts
# A directory for each artifact is created using its name
- name: Download all workflow run artifacts
uses: actions/download-artifact@v3
with:
path: assets
- name: Display structure of downloaded files
run: ls -R
working-directory: assets
- name: Create release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
hub release create --draft --message="Release draft from Github Actions" vNext
for i in $(find ./assets -name '*.tgz' -type f); do
hub release edit --attach=${i} --message="" vNext
done