Skip to content

fix implementation of skip logic (skip more events) #128

fix implementation of skip logic (skip more events)

fix implementation of skip logic (skip more events) #128

name: Build latest master version
on:
push:
branches:
- 'master'
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
run_tests:
name: Run Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 18.15.0
- run: npm install
- run: npm run test-coverage
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
build_binaries:
name: Build Binaries
needs: [ run_tests ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# setup global dependencies
- uses: actions/setup-node@v3
with:
node-version: 18.15.0
- run: npm install -g pkg
# build server project
- run: |
npm install
npm run bundle
# build client project
- run: |
cd faucet-client
npm install
node ./build-client.js
# package bundled release
- name: Package bundled release
run: |
mv res/run-faucet.* ./
chmod +x ./run-faucet.sh
tar cfz powfaucet-server-all.tar.gz dist static faucet-config.example.yaml run-faucet.sh
zip -r powfaucet-server-all.zip dist static faucet-config.example.yaml run-faucet.bat
# package static folder
- name: Package static folder
run: |
tar cfz powfaucet-static.tar.gz static
zip -r powfaucet-static.zip static
# build binaries
- run: pkg --compress Brotli --options no-warnings .
# collect metadata
- name: Get project versions
run: |
echo "server_version=$(cat package.json | jq ".version" | tr -d '"\r\n')" >> $GITHUB_OUTPUT
echo "client_version=$(cat faucet-client/package.json | jq ".version" | tr -d '"\r\n')" >> $GITHUB_OUTPUT
id: version
# (re)create snapshot binary release
- name: Update snapshot tag & remove previous snapshot release
uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
try {
var snapshotTag = "snapshot";
var snapshotRelease = await github.repos.getReleaseByTag({
owner: context.repo.owner,
repo: context.repo.repo,
tag: snapshotTag
});
if(snapshotRelease && snapshotRelease.data && snapshotRelease.data.tag_name == snapshotTag) {
console.log("delete previous snapshot release");
await github.repos.deleteRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: snapshotRelease.data.id
});
}
var snapshotRef = await github.git.getRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/" + snapshotTag
});
if(snapshotRef && snapshotRef.data && snapshotRef.data.ref) {
if(snapshotRef.data.object.sha !== context.sha) {
await github.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/" + snapshotTag,
sha: context.sha,
});
}
}
else {
await github.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/" + snapshotTag,
sha: context.sha,
});
}
} catch (e) {
console.log(e)
}
- name: Create snapshot release
uses: actions/create-release@v1
id: create_release
with:
draft: false
prerelease: true
release_name: "Dev Snapshot"
tag_name: "snapshot"
body: |
## Latest automatically built v2 executables. (Unstable development snapshot)
Built from master branch (commit: ${{ github.sha }})
Please read the [Operator Wiki](https://github.com/pk910/PoWFaucet/wiki/Operator-Wiki) for setup / configuration instructions.
Server Version: ${{ steps.version.outputs.server_version }}
Client Version: ${{ steps.version.outputs.client_version }}
### Release Artifacts
| Release File | Description |
| ------------- | ------------- |
| powfaucet-server-all [.tar.gz](https://github.com/pk910/PoWFaucet/releases/download/snapshot/powfaucet-server-all.tar.gz) / [.zip](https://github.com/pk910/PoWFaucet/releases/download/snapshot/powfaucet-server-all.zip) | PoWFaucet server for execution with local nodejs (recommended) |
| [powfaucet-server-win.exe](https://github.com/pk910/PoWFaucet/releases/download/snapshot/powfaucet-server-win.exe) | PoWFaucet all-in-one executable for windows (NodeJS 18, 64bit) |
| [powfaucet-server-linux](https://github.com/pk910/PoWFaucet/releases/download/snapshot/powfaucet-server-linux) | PoWFaucet all-in-one executable for linux (NodeJS 18, 64bit) |
| powfaucet-static [.tar.gz](https://github.com/pk910/PoWFaucet/releases/download/snapshot/powfaucet-static.tar.gz) / [.zip](https://github.com/pk910/PoWFaucet/releases/download/snapshot/powfaucet-static.zip) | PoWFaucet static folder (optional, see [Operator Wiki](https://github.com/pk910/PoWFaucet/wiki/Operator-Wiki)) |
env:
GITHUB_TOKEN: ${{ github.token }}
# upload release artifacts
- name: "Upload artifact: powfaucet-server-linux"
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/pow-faucet-server-linux
asset_name: powfaucet-server-linux
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ github.token }}
- name: "Upload artifact: powfaucet-server-win.exe"
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./dist/pow-faucet-server-win.exe
asset_name: powfaucet-server-win.exe
asset_content_type: application/octet-stream
env:
GITHUB_TOKEN: ${{ github.token }}
- name: "Upload artifact: powfaucet-server-all.tar.gz"
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./powfaucet-server-all.tar.gz
asset_name: powfaucet-server-all.tar.gz
asset_content_type: application/gzip
env:
GITHUB_TOKEN: ${{ github.token }}
- name: "Upload artifact: powfaucet-server-all.zip"
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./powfaucet-server-all.zip
asset_name: powfaucet-server-all.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ github.token }}
- name: "Upload artifact: powfaucet-static.tar.gz"
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./powfaucet-static.tar.gz
asset_name: powfaucet-static.tar.gz
asset_content_type: application/gzip
env:
GITHUB_TOKEN: ${{ github.token }}
- name: "Upload artifact: powfaucet-static.zip"
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./powfaucet-static.zip
asset_name: powfaucet-static.zip
asset_content_type: application/zip
env:
GITHUB_TOKEN: ${{ github.token }}
build_docker:
name: Build Docker Image
needs: [run_tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build v2-latest docker image
run: docker build . --file Dockerfile --tag pk910/powfaucet:v2-latest
- name: Push v2-latest docker image
run: docker push pk910/powfaucet:v2-latest