mirror of
https://github.com/unraid/api.git
synced 2025-12-31 13:39:52 -06:00
179 lines
5.3 KiB
YAML
179 lines
5.3 KiB
YAML
name: Pull Request
|
|
|
|
on:
|
|
pull_request:
|
|
paths:
|
|
- '**.js'
|
|
- '**.ts'
|
|
|
|
|
|
concurrency:
|
|
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
lint-api:
|
|
continue-on-error: true
|
|
defaults:
|
|
run:
|
|
working-directory: api
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
- name: Reconfigure git to use HTTP authenti:cation
|
|
run: >
|
|
git config --global url."https://github.com/".insteadOf
|
|
ssh://git@github.com/
|
|
|
|
- name: Install node
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version-file: "api/.nvmrc"
|
|
|
|
# - name: Cache dependencies
|
|
# uses: actions/cache@v2
|
|
# with:
|
|
# path: ~/.npm
|
|
# key: npm-${{ hashFiles('package-lock.json') }}
|
|
# restore-keys: npm-
|
|
|
|
- name: Install libvirt-dev
|
|
run: sudo apt-get update && sudo apt-get install libvirt-dev
|
|
|
|
- name: Installing node deps
|
|
run: npm ci
|
|
|
|
- name: Lint files
|
|
run: npm run lint
|
|
|
|
test-api:
|
|
defaults:
|
|
run:
|
|
working-directory: api
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v3
|
|
with:
|
|
persist-credentials: false
|
|
|
|
- name: Reconfigure git to use HTTP authentication
|
|
run: >
|
|
git config --global url."https://github.com/".insteadOf
|
|
ssh://git@github.com/
|
|
|
|
- name: Build Docker Compose
|
|
run: |
|
|
docker network create mothership_default
|
|
docker-compose build builder
|
|
- name: Run Docker Compose
|
|
run: docker-compose run builder npm run coverage
|
|
|
|
build-api:
|
|
defaults:
|
|
run:
|
|
working-directory: api
|
|
runs-on: ubuntu-latest
|
|
|
|
outputs:
|
|
API_VERSION: ${{ steps.build-pack-binary.outputs.API_VERSION }}
|
|
API_MD5: ${{ steps.set-hashes.outputs.API_MD5 }}
|
|
API_SHA256: ${{ steps.set-hashes.outputs.API_SHA256 }}
|
|
|
|
steps:
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Install node
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version-file: "api/.nvmrc"
|
|
|
|
- name: Install libvirt-dev
|
|
run: sudo apt-get update && sudo apt-get install libvirt-dev
|
|
|
|
# - name: Cache dependencies
|
|
# uses: actions/cache@v2
|
|
# with:
|
|
# path: ~/.npm
|
|
# key: npm-${{ hashFiles('package-lock.json') }}
|
|
# restore-keys: npm-
|
|
|
|
- name: Installing node deps
|
|
run: npm install
|
|
|
|
- name: Install pkg
|
|
run: npm i -g pkg
|
|
|
|
- name: Build and Pack
|
|
id: build-pack-binary
|
|
run: WORKDIR=${{ github.workspace }} && npm run build-pkg
|
|
|
|
- name: Set Hashes
|
|
id: set-hashes
|
|
run: |
|
|
API_MD5=$(md5sum ${{ github.workspace }}/api/deploy/release/*.tgz | awk '{ print $1 }')
|
|
API_SHA256=$(sha256sum ${{ github.workspace }}/api/deploy/release/*.tgz | awk '{ print $1 }')
|
|
echo "::set-output name=API_MD5::${API_MD5}"
|
|
echo "::set-output name=API_SHA256::${API_SHA256}"
|
|
|
|
- name: Upload tgz to Github artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: unraid-api
|
|
path: ${{ github.workspace }}/api/deploy/release/*.tgz
|
|
|
|
- name: Parse Changelog
|
|
id: changelog
|
|
uses: ocavue/changelog-parser-action@v1
|
|
with:
|
|
removeMarkdown: false
|
|
filePath: "./api/CHANGELOG.md"
|
|
|
|
- name: View release notes
|
|
run: |
|
|
escapedNotes=$(sed -e 's/[&\\/]/\\&/g; s/$/\\/' -e '$s/\\$//' <<<"${{steps.changelog.outputs.latestBody}}")
|
|
echo "${escapedNotes}"
|
|
build-plugin:
|
|
defaults:
|
|
run:
|
|
working-directory: plugin
|
|
runs-on: ubuntu-latest
|
|
needs: [lint-api, test-api, build-api]
|
|
steps:
|
|
- name: Set Timezone
|
|
uses: szenius/set-timezone@v1.2
|
|
with:
|
|
timezoneLinux: "America/Los_Angeles"
|
|
- name: Checkout repo
|
|
uses: actions/checkout@v3
|
|
- name: Build Plugin
|
|
run: |
|
|
cd source/dynamix.unraid.net
|
|
export API_VERSION=${{needs.build-api.outputs.API_VERSION}}
|
|
export API_MD5=${{needs.build-api.outputs.API_MD5}}
|
|
export API_SHA256=${{needs.build-api.outputs.API_SHA256}}
|
|
bash ./pkg_build.sh s
|
|
bash ./pkg_build.sh p
|
|
- name: Create release notes
|
|
run: |
|
|
LAST_RELEASE=$(git tag --list --sort=v:refname | tail -1)
|
|
echo ${LAST_RELEASE}
|
|
RELEASE_NOTES=$(git log "$LAST_RELEASE...HEAD" --pretty=format:"- %s [\`%h\`](http://github.com/$GITHUB_REPOSITORY/commit/%H)" --reverse)
|
|
echo "${RELEASE_NOTES}"
|
|
# escapedNotes=$(sed -e 's/[&\\/]/\\&/g; s/$/\\/' -e '$s/\\$//' <<<"${RELEASE_NOTES}")
|
|
# sed -i -z -E "s/<CHANGES>(.*)<\/CHANGES>/<CHANGES>\n${escapedNotes}\n<\/CHANGES>/g" "plugins/dynamix.unraid.net.staging.plg"
|
|
- name: Upload binary txz and plg to Github artifacts
|
|
uses: actions/upload-artifact@v3
|
|
with:
|
|
name: connect-files
|
|
path: |
|
|
${{ github.workspace }}/plugin/archive/*.txz
|
|
${{ github.workspace }}/plugin/plugins/*.plg
|
|
retention-days: 5
|
|
if-no-files-found: error
|