name: Build and Release # Releases are driven by the version in package.json: bump it (e.g. # `npm version patch --no-git-tag-version`) and push to main. If no tag # v exists yet, the release job pushes the Docker image and creates # the tag and Gitea release. Build and release run in sequence in one # workflow, so they never race for the runner's action cache. on: push: branches: - main - develop pull_request: branches: - main jobs: build: runs-on: ubuntu-latest steps: - uses: https://github.com/actions/checkout@v4 - name: Set up Docker Buildx uses: https://github.com/docker/setup-buildx-action@v3 with: config-inline: | [registry."gitea.sanplex.xyz/sansan"] http = true insecure = true - name: Build Docker image uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile push: false cache-from: type=gha cache-to: type=gha,mode=max release: needs: build if: github.event_name == 'push' && github.ref == 'refs/heads/main' runs-on: ubuntu-latest steps: - uses: https://github.com/actions/checkout@v4 with: fetch-depth: 0 fetch-tags: true - name: Check version id: version run: | VERSION="v$(node -p "require('./package.json').version")" echo "tag=$VERSION" >> "$GITHUB_OUTPUT" if git rev-parse -q --verify "refs/tags/$VERSION" >/dev/null; then echo "$VERSION already released, nothing to do" echo "release=false" >> "$GITHUB_OUTPUT" else echo "Releasing $VERSION" echo "release=true" >> "$GITHUB_OUTPUT" fi - name: Set up QEMU if: steps.version.outputs.release == 'true' uses: https://github.com/docker/setup-qemu-action@v3 - name: Set up Docker Buildx if: steps.version.outputs.release == 'true' uses: https://github.com/docker/setup-buildx-action@v3 with: config-inline: | [registry."gitea.sanplex.xyz/sansan"] http = true insecure = true - name: Login to Gitea Container Registry if: steps.version.outputs.release == 'true' uses: docker/login-action@v3 with: registry: gitea.sanplex.xyz username: sansan password: ${{ secrets.TOKEN }} - name: Build and push multi-arch image if: steps.version.outputs.release == 'true' uses: docker/build-push-action@v5 with: context: . file: ./Dockerfile platforms: linux/amd64,linux/arm64 push: true tags: | gitea.sanplex.xyz/sansan/musicfrontend:${{ steps.version.outputs.tag }} gitea.sanplex.xyz/sansan/musicfrontend:latest cache-from: type=gha cache-to: type=gha,mode=max - name: Create Release if: steps.version.outputs.release == 'true' uses: akkuman/gitea-release-action@v1 env: NODE_OPTIONS: '--experimental-fetch' # if nodejs < 18 with: tag_name: ${{ steps.version.outputs.tag }} target_commitish: ${{ github.sha }} body: | Docker image: `gitea.sanplex.xyz/sansan/musicfrontend:${{ steps.version.outputs.tag }}`