forked from btcsuite/btcd
-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:pkt-cash/pktd
- Loading branch information
Showing
6 changed files
with
265 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
on: | ||
push: | ||
tags: | ||
- pktd-v*.*.* | ||
|
||
jobs: | ||
release: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- name: Set env | ||
run: echo "RELEASE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
|
||
- name: Create a release | ||
uses: "marvinpinto/action-automatic-releases@latest" | ||
with: | ||
repo_token: ${{ secrets.GITHUB_TOKEN }} | ||
prerelease: false | ||
automatic_release_tag: ${{ env.RELEASE_NAME }} | ||
|
||
linux: | ||
needs: release | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
|
||
- name: Set env | ||
run: echo "RELEASE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
|
||
- name: Install packages | ||
run: sudo apt-get install rpm jq bash curl rubygems | ||
|
||
- name: Set up Ruby 2.6 | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.6 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
|
||
- run: go version | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
- name: Install fpm | ||
run: gem install --no-document fpm | ||
|
||
- name: Build binaries | ||
run: /bin/bash -c "source $GITHUB_WORKSPACE/contrib/github-actions/build-linux-packages.sh" | ||
env: | ||
PKT_FAIL_DIRTY: 1 | ||
RELEASE_NAME: ${{ env.RELEASE_NAME }} | ||
|
||
- uses: actions/upload-artifact@main | ||
with: | ||
path: | | ||
${{ github.workspace }}/${{ env.RELEASE_NAME }}-linux-x86_64.rpm | ||
${{ github.workspace }}/${{ env.RELEASE_NAME }}-linux-amd64.deb | ||
- name: Publish release | ||
run: /bin/bash -c "source $GITHUB_WORKSPACE/contrib/github-actions/release-linux-packages.sh" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
RELEASE_NAME: ${{ env.RELEASE_NAME }} | ||
|
||
macos: | ||
needs: release | ||
|
||
runs-on: macos-latest | ||
|
||
steps: | ||
|
||
- name: Set env | ||
run: echo "RELEASE_NAME=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV | ||
|
||
- name: Install packages | ||
run: brew install jq bash curl brew-gem | ||
|
||
- name: Set up Ruby 2.6 | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 2.6 | ||
|
||
- name: Install Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.16.x | ||
|
||
- run: go version | ||
|
||
- uses: actions/checkout@v2 | ||
|
||
- name: Install fpm | ||
run: gem install --no-document fpm | ||
|
||
- name: Build binaries | ||
run: /bin/bash -c "source $GITHUB_WORKSPACE/contrib/github-actions/build-macos-package.sh" | ||
env: | ||
PKT_FAIL_DIRTY: 1 | ||
RELEASE_NAME: ${{ env.RELEASE_NAME }} | ||
|
||
- uses: actions/upload-artifact@main | ||
with: | ||
path: | | ||
${{ github.workspace }}/${{ env.RELEASE_NAME }}-mac.pkg | ||
- name: Publish release | ||
run: /bin/bash -c "source $GITHUB_WORKSPACE/contrib/github-actions/release-macos-package.sh" | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
RELEASE_NAME: ${{ env.RELEASE_NAME }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -51,3 +51,5 @@ _testmain.go | |
/goleveldb/gocov_report_goleveldb.json | ||
/cov/ | ||
|
||
*.rpm | ||
*.deb |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
|
||
function build() { | ||
cd "${GITHUB_WORKSPACE}" || exit | ||
source ./do | ||
|
||
cd "${GITHUB_WORKSPACE}" || exit | ||
bash -x ./contrib/deb/build.sh | ||
|
||
local VERSION | ||
VERSION=$(echo "${RELEASE_NAME}" | sed -E 's/.+v//') | ||
|
||
mv -v "${GITHUB_WORKSPACE}"'/pktd-linux_'"${VERSION}"'_amd64.deb' \ | ||
"${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"'-linux-amd64.deb' | ||
|
||
cd "${GITHUB_WORKSPACE}" || exit | ||
bash -x ./contrib/rpm/build.sh | ||
|
||
mv -v "${GITHUB_WORKSPACE}"'/pktd-linux-'"${VERSION}"'-1.x86_64.rpm' \ | ||
"${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"'-linux-x86_64.rpm' | ||
} | ||
build |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
function build() { | ||
cd "${GITHUB_WORKSPACE}" || exit | ||
source ./do | ||
|
||
cd "${GITHUB_WORKSPACE}" || exit | ||
bash -x ./contrib/macos/build.sh | ||
|
||
local VERSION | ||
VERSION=$(echo "${RELEASE_NAME}" | sed -E 's/.+-v//') | ||
|
||
mv -v "${GITHUB_WORKSPACE}"'/pktd-mac-'"${VERSION}"'.pkg' \ | ||
"${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"'-mac.pkg' | ||
} | ||
build |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/bash | ||
|
||
function publish() { | ||
local binary | ||
binary="${1}" | ||
|
||
local extension | ||
extension="${2}" | ||
|
||
if [ ! -e "${binary}" ]; | ||
then | ||
echo 'Invalid binary ('"${binary}"')' | ||
return 1 | ||
fi | ||
|
||
local checksum | ||
checksum="$(sha256sum "${binary}" | cut -d ' ' -f 1)" | ||
|
||
local base_url | ||
base_url='https://api.github.com/repos/'"${GITHUB_REPOSITORY}" | ||
|
||
local upload_url | ||
upload_url="$(curl \ | ||
-H 'Content-Type: application/octet-stream' \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
"${base_url}"/releases 2>> /dev/null | \ | ||
jq -r '.[] | .upload_url' | \ | ||
head -n1)" | ||
|
||
upload_url=${upload_url/\{?name,label\}/} | ||
|
||
local release_name | ||
release_name="$(curl \ | ||
-H 'Content-Type: application/octet-stream' \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
"${base_url}"/releases 2>> /dev/null | \ | ||
jq -r '.[] | .tag_name' | \ | ||
head -n1)" | ||
|
||
curl \ | ||
-X POST \ | ||
--data-binary @${binary} \ | ||
-H 'Content-Type: application/octet-stream' \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
"${upload_url}?name=${release_name}${extension}" | ||
|
||
curl \ | ||
-X POST \ | ||
--data "$checksum" \ | ||
-H 'Content-Type: text/plain' \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
"${upload_url}?name=${release_name}${extension}.sha256sum" | ||
} | ||
|
||
publish "${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"'-linux-x86_64.rpm' '.rpm' | ||
publish "${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"'-linux-amd64.deb' '.deb' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/bin/bash | ||
|
||
function publish() { | ||
local binary | ||
binary="${1}" | ||
|
||
local extension | ||
extension="${2}" | ||
|
||
if [ ! -e "${binary}" ]; | ||
then | ||
echo 'Invalid binary ('"${binary}"')' | ||
return 1 | ||
fi | ||
|
||
local checksum | ||
checksum=$(shasum -a256 "${binary}" | cut -d ' ' -f 1) | ||
|
||
local base_url | ||
base_url='https://api.github.com/repos/'"${GITHUB_REPOSITORY}" | ||
|
||
local upload_url | ||
upload_url="$(curl \ | ||
-H 'Content-Type: application/octet-stream' \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
"${base_url}"/releases 2>> /dev/null | \ | ||
jq -r '.[] | .upload_url' | \ | ||
head -n1)" | ||
upload_url=${upload_url/\{?name,label\}/} | ||
|
||
local release_name | ||
release_name="$(curl \ | ||
-H 'Content-Type: application/octet-stream' \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
"${base_url}"/releases 2>> /dev/null | \ | ||
jq -r '.[] | .tag_name' | \ | ||
head -n1)" | ||
|
||
curl \ | ||
-X POST \ | ||
--data-binary @${binary} \ | ||
-H 'Content-Type: application/octet-stream' \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
"${upload_url}?name=${release_name}${extension}" | ||
|
||
curl \ | ||
-X POST \ | ||
--data "$checksum" \ | ||
-H 'Content-Type: text/plain' \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
"${upload_url}?name=${release_name}${extension}.sha256sum" | ||
} | ||
|
||
publish "${GITHUB_WORKSPACE}"'/'"${RELEASE_NAME}"'-mac.pkg' '.pkg' |