Merge branch 'V2' #52
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
name: Build | |
on: | |
release: | |
types: [published] | |
push: | |
jobs: | |
BuildBinary: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
packages: write | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Setup Node.js environment | |
uses: actions/setup-node@v3.6.0 | |
with: | |
node-version: 18.x | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install -y jq | |
- name: Build | |
run: | | |
export VERSION="`if [[ $GITHUB_REF == refs\/tags* ]]; then echo ${GITHUB_REF//refs\/tags\//}; fi`" | |
if [ "$VERSION" = "" ]; | |
then | |
export VERSION="SNAPSHOT" | |
fi | |
bash build.sh | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v2 | |
with: | |
name: hypergate | |
path: deploy | |
- name: Deploy to GitHub Releases | |
if: github.event_name == 'release' | |
run: | | |
echo "${GITHUB_EVENT_PATH}" | |
cat ${GITHUB_EVENT_PATH} | |
releaseId=$(jq --raw-output '.release.id' ${GITHUB_EVENT_PATH}) | |
echo "Upload binary to $releaseId" | |
filename=deploy/hypergate | |
url="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/$releaseId/assets?name=$(basename $filename)" | |
echo "Upload to $url" | |
curl -L \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: application/octet-stream" \ | |
--data-binary @"$filename" \ | |
"$url" | |
echo "Upload hash to $releaseId" | |
filename=deploy/hypergate.sha256 | |
url="https://uploads.github.com/repos/${GITHUB_REPOSITORY}/releases/$releaseId/assets?name=$(basename $filename)" | |
echo "Upload to $url" | |
curl -L \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Content-Type: text/plain" \ | |
--data-binary @"$filename" \ | |
"$url" | |
BuildContainer: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: | | |
sudo apt update | |
sudo apt install -y jq | |
- name: Build and push to registry | |
run: | | |
VERSION="snapshot" | |
if [[ $GITHUB_REF == refs/tags/* ]]; then | |
VERSION=${GITHUB_REF#refs/tags/} | |
fi | |
bash setversion.sh | |
echo ${{ secrets.GITHUB_TOKEN }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin | |
docker build -t hypergate:$VERSION . -f docker/Dockerfile | |
docker tag hypergate:$VERSION docker.pkg.github.com/${{ github.repository }}/hypergate:${VERSION} | |
docker push docker.pkg.github.com/${{ github.repository }}/hypergate:${VERSION} |