build: using internal nx plugin for test and publish #19
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: Release | |
on: | |
push: | |
branches: | |
- main | |
permissions: | |
pull-requests: write | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
outputs: | |
released: ${{ steps.release.outputs.releases_created }} | |
projects: ${{ steps.packages.outputs.projects }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- name: Release Please | |
id: release | |
uses: googleapis/release-please-action@7987652d64b4581673a76e33ad5e98e3dd56832f # v4 | |
with: | |
token: ${{ secrets.GH_BOT_TOKEN }} | |
config-file: release-config.json | |
manifest-file: release-manifest.json | |
- name: Prepare list released packages | |
id: packages | |
if: steps.release.outputs.releases_created == 'true' | |
run: | | |
paths_released=$(echo '${{ steps.release.outputs.paths_released }}' | jq -r '. | .[]') | |
echo "Release paths: ${paths_released[@]}" | |
projects=() | |
for projectPath in $paths_released; do | |
if [[ "$projectPath" != "." ]]; then | |
projectFile="$projectPath/project.json" | |
projectName=$(jq -r '.name' "$projectFile") | |
projects+=("$projectName") | |
fi | |
done | |
echo "Projects: ${applications[@]}" | |
echo "projects=$(printf '%s\n' "${projects[@]}" | jq -R . | jq -s . | jq -c .)" >> $GITHUB_OUTPUT | |
publish: | |
name: Publish | |
runs-on: ubuntu-latest | |
needs: release | |
if: ${{ needs.release.outputs.released == 'true' && needs.release.outputs.projects != '[""]' }} | |
strategy: | |
matrix: | |
project: ${{fromJson(needs.release.outputs.projects)}} | |
steps: | |
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 | |
- uses: ./.github/actions/setup | |
with: | |
dependencies: true | |
buildx: true | |
- name: Login to Docker Hub container registry | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3 | |
with: | |
registry: docker.io | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Login to GitHub container registry | |
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3 | |
with: | |
registry: ghcr.io | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GH_BOT_TOKEN }} | |
- run: npx nx publish ${{ matrix.project }} | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }} |