name: Release defaults: run: shell: bash env: DOCKER_TAG: "ghcr.io/${{ github.repository }}:${{ github.ref_name }}" on: push: tags: - v[0-9]+.* jobs: base: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - uses: taiki-e/install-action@v2 with: tool: parse-changelog - name: Generate changelog run: | VERSION_MINUS_V=${GITHUB_REF_NAME/#v/} parse-changelog CHANGELOG.md $VERSION_MINUS_V > CHANGELOG-$GITHUB_REF_NAME.md - uses: actions/setup-node@v3 with: node-version: 18 - run: npm i -g pnpm - run: cd ui && pnpm i --frozen-lockfile - run: cd ui && pnpm run build - run: cd ui && pnpm run test # Upload the UI and changelog as *job* artifacts (not *release* artifacts), used below. - uses: actions/upload-artifact@v3 with: name: moonfire-nvr-ui-${{ github.ref_name }} path: ui/dist if-no-files-found: error - uses: actions/upload-artifact@v3 with: name: CHANGELOG-${{ github.ref_name }} path: CHANGELOG-${{ github.ref_name }}.md if-no-files-found: error cross: needs: base # for bundled ui permissions: contents: read packages: write strategy: matrix: include: # Note: keep these arches in sync with `Upload Docker Manifest` list. - arch: x86_64 # as in `uname -m` on Linux. rust_target: x86_64-unknown-linux-musl # as in docker_platform: linux/amd64 # as in - arch: aarch64 rust_target: aarch64-unknown-linux-musl docker_platform: linux/arm64 - arch: armv7l rust_target: armv7-unknown-linux-musleabihf docker_platform: linux/arm/v7 runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v4 - name: Download UI uses: actions/download-artifact@v3 with: name: moonfire-nvr-ui-${{ github.ref_name }} path: ui/dist # actions-rust-cross doesn't actually use cross for x86_64. # Install the needed musl-tools in the host. - name: Install musl-tools run: sudo apt-get --option=APT::Acquire::Retries=3 update && sudo apt-get --option=APT::Acquire::Retries=3 install musl-tools if: matrix.rust_target == 'x86_64-unknown-linux-musl' - name: Build uses: houseabsolute/actions-rust-cross@v0 env: UI_BUILD_DIR: ../ui/dist # cross doesn't install `git` within its Docker container, so plumb # the version through rather than try `git describe` from `build.rs`. VERSION: ${{ github.ref_name }} with: working-directory: server target: ${{ matrix.rust_target }} command: build args: --release --features bundled - name: Upload Docker Artifact run: | tag="${DOCKER_TAG}-${{ matrix.arch }}" mkdir output ln ./server/target/${{ matrix.rust_target }}/release/moonfire-nvr output/ echo ${{secrets.GITHUB_TOKEN}} | docker login --username ${{github.actor}} --password-stdin ghcr.io docker build --platform ${{ matrix.docker_platform }} --push --tag "${tag}" --file - output <