-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
238 additions
and
331 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,78 +1,149 @@ | ||
name: Generate attachments | ||
name: PR Build | ||
|
||
on: | ||
# This workflow is started only on PRs | ||
pull_request_target: | ||
types: | ||
pull_request_target: | ||
types: | ||
- opened | ||
- reopened | ||
- synchronize | ||
paths: | ||
- 'Java/**' | ||
- 'JS/**' | ||
|
||
jobs: | ||
# Main job | ||
build: | ||
permissions: | ||
# Required to upload/save artifact, otherwise you'll get | ||
# "Error: Resource not accessible by integration" | ||
contents: write | ||
# Required to post comment, otherwise you'll get | ||
# "Error: Resource not accessible by integration" | ||
pull-requests: write | ||
|
||
changes: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
pull-requests: read | ||
outputs: | ||
VALUE: ${{ steps.short_hash.outputs.VALUE }} | ||
java: ${{ steps.filter.outputs.java }} | ||
js: ${{ steps.filter.outputs.js }} | ||
steps: | ||
# Put your steps here to generate the files to upload. | ||
# Usually configure Node.js, build, etc. | ||
# Finally, upload the artifacts and post comment: | ||
- name: Checkout PR | ||
if: ${{ github.event_name == 'pull_request_target' }} | ||
uses: actions/checkout@v3 | ||
- uses: dorny/paths-filter@v2 | ||
id: filter | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
repository: ${{ github.event.pull_request.head.repo.full_name }} | ||
filters: | | ||
java: | ||
- 'Java/**' | ||
js: | ||
- 'JS/**' | ||
java: | ||
needs: changes | ||
if: ${{ needs.changes.outputs.java == 'true' }} | ||
runs-on: ubuntu-latest | ||
outputs: | ||
VALUE: ${{ steps.set_short_hash.outputs.VALUE }} | ||
|
||
# Token for current repo (used to post PR comment) | ||
repo-token: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set SHORT_HASH | ||
id: set_short_hash | ||
run: | | ||
echo "::set-output name=VALUE::${LONG_HASH:0:8}" | ||
echo "RELEASE_TAG=${LONG_HASH:0:8}-$(TZ=UTC-8 date +"%Y.%m.%d")" >> $GITHUB_ENV | ||
id: short_hash | ||
env: | ||
LONG_HASH: ${{ github.sha }} | ||
echo "::set-output name=VALUE::${{ github.sha }}" | ||
echo "RELEASE_TAG=${{ github.sha }}-$(TZ=UTC-8 date +"%Y.%m.%d")" >> $GITHUB_ENV | ||
- name: Goto Java folder | ||
run: cd Java | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v3 | ||
uses: actions/setup-java@v2 | ||
with: | ||
java-version: '17' | ||
distribution: 'adopt' | ||
java-version: '17' | ||
|
||
- name: Set up Maven | ||
uses: stCarolas/[email protected] | ||
with: | ||
maven-version: 3.9.3 | ||
|
||
- name: Create output folder | ||
run: mkdir BuildOutput | ||
run: mkdir -p Java/FlySpring/edgechain-app/BuildOutput | ||
|
||
- name: Build edgechain-app project | ||
working-directory: ./FlySpring/edgechain-app | ||
run: mvn clean package -DskipTests | ||
working-directory: Java/FlySpring/edgechain-app | ||
run: mvn clean package -DskipTests | ||
|
||
- name: Run edgechain testcases | ||
working-directory: ./FlySpring/edgechain-app | ||
working-directory: Java/FlySpring/edgechain-app | ||
run: mvn test | ||
|
||
- name: Copy edgechain-app JAR to Examples folder | ||
run: cp ./FlySpring/edgechain-app/target/edgechain.jar ./BuildOutput/ | ||
- name: Copy edgechain-app JAR to BuildOutput | ||
run: cp Java/FlySpring/edgechain-app/target/edgechain.jar Java/FlySpring/edgechain-app/BuildOutput | ||
|
||
|
||
js: | ||
needs: changes | ||
if: ${{ needs.changes.outputs.js == 'true' }} | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '18' | ||
- name: Install Prettier | ||
run: npm install prettier | ||
- name: Install ESLint | ||
run: > | ||
npm install eslint@latest && | ||
npm install @microsoft/eslint-formatter-sarif@latest eslint-config-google@latest eslint-plugin-import@latest @typescript-eslint/eslint-plugin@latest @typescript-eslint/parser@latest eslint-config-prettier@latest eslint-plugin-prettier@latest | ||
- name: Get cache date | ||
id: get-date | ||
run: echo "name=date::$(/bin/date -u "+%Y%m%d")" | ||
shell: bash | ||
- name: ESLint Cache | ||
uses: actions/cache@v3 | ||
with: | ||
path: ./.eslintcache | ||
key: ${{ runner.os }}-eslintcache-${{ hashFiles('./eslintcache') }} | ||
restore-keys: | | ||
${{ runner.os }}-eslintcache- | ||
- name: Run ESLint | ||
run: npx eslint JS | ||
--fix | ||
--cache | ||
--config JS/.eslintrc.js | ||
--ext .js,.jsx,.ts,.tsx | ||
continue-on-error: true | ||
|
||
- name: Run Prettiers | ||
run: npx prettier --tab-width 4 --print-width 100 --trailing-comma es5 --ignore-path "$(CURDIR)/node_modules/*" --write JS/ | ||
- name: Commit changes | ||
uses: stefanzweifel/git-auto-commit-action@v4 | ||
with: | ||
commit_message: Automatically applying Prettier changes | ||
commit_user_name: GitHub Actions | ||
commit_user_email: [email protected] | ||
commit_author: GitHub Actions <[email protected]> | ||
branch: ${{ github.head_ref }} | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Goto JS folder | ||
run: cd JS/edgechains/lib | ||
|
||
- name: Upload Examples folder as artifact | ||
uses: actions/upload-artifact@v3 | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
name: Output | ||
path: ./BuildOutput/ | ||
node-version: '18' | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
working-directory: JS/edgechains/lib | ||
|
||
- name: Build edgechain-app project | ||
run: npm run build | ||
working-directory: JS/edgechains/lib | ||
|
||
|
||
- name: Package edgechain-app project | ||
run: npm pack | ||
working-directory: JS/edgechains/lib |
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,78 @@ | ||
name: Release Java | ||
|
||
on: | ||
workflow_dispatch | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
VALUE: ${{ steps.set_short_hash.outputs.VALUE }} | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set SHORT_HASH | ||
id: set_short_hash | ||
run: | | ||
echo "::set-output name=VALUE::${{ github.sha }}" | ||
echo "RELEASE_TAG=${{ github.sha }}-$(TZ=UTC-8 date +"%Y.%m.%d")" >> $GITHUB_ENV | ||
- name: Goto Java folder | ||
run: cd Java | ||
|
||
- name: Set up JDK | ||
uses: actions/setup-java@v2 | ||
with: | ||
distribution: 'adopt' | ||
java-version: '17' | ||
|
||
- name: Set up Maven | ||
uses: stCarolas/[email protected] | ||
with: | ||
maven-version: 3.9.3 | ||
|
||
- name: Create output folder | ||
run: mkdir -p Java/FlySpring/edgechain-app/BuildOutput | ||
|
||
- name: Build edgechain-app project | ||
working-directory: Java/FlySpring/edgechain-app | ||
run: mvn clean package -DskipTests | ||
|
||
- name: Run edgechain testcases | ||
working-directory: Java/FlySpring/edgechain-app | ||
run: mvn test | ||
|
||
- name: Copy edgechain-app JAR to Examples folder | ||
run: cp Java/FlySpring/edgechain-app/target/edgechain.jar Java/FlySpring/edgechain-app/BuildOutput | ||
|
||
- name: Upload Examples folder as artifact | ||
uses: actions/upload-artifact@v2 | ||
with: | ||
name: Output | ||
path: Java/FlySpring/edgechain-app/BuildOutput | ||
|
||
release: | ||
name: release-java | ||
needs: build | ||
if: startsWith(github.ref, 'refs/tags/') | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download jar from build | ||
uses: actions/download-artifact@v2 | ||
with: | ||
name: Output | ||
path: Output | ||
- name: Display structure of downloaded files | ||
run: ls -R | ||
|
||
- name: Get variables | ||
id: vars | ||
run: echo "tag_name=${{ env.RELEASE_TAG }}" >> $GITHUB_ENV | ||
|
||
- name: Release | ||
uses: softprops/action-gh-release@v1 | ||
with: | ||
files: | | ||
./Output/**/*.* | ||
tag_name: ${{ env.RELEASE_TAG }} |
Oops, something went wrong.