Skip to content

Version Packages (#152) #121

Version Packages (#152)

Version Packages (#152) #121

Workflow file for this run

name: Release
on:
push:
branches:
- main
# allow action to create tags and pull request
permissions:
contents: write
pull-requests: write
concurrency: ${{ github.workflow }}-${{ github.ref }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
outputs:
publishedPackages: ${{ steps.changesets.outputs.publishedPackages }}
# To use Turborepo Remote Caching
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node.js 20
uses: actions/setup-node@v3
with:
node-version: 20
cache: 'npm'
- name: Creating .npmrc
run: |
cat << EOF > "$HOME/.npmrc"
//registry.npmjs.org/:_authToken=$NPM_TOKEN
EOF
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Install Dependencies
run: npm ci
- name: Create Release Pull Request or Publish to npm
id: changesets
uses: changesets/action@v1
with:
publish: npm run release
version: npm run version
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
docker:
name: Publish to Docker Hub
needs: release
runs-on: ubuntu-latest
if: contains(needs.release.outputs.publishedPackages, 'caravan-coordinator')
steps:
- name: Parse Package Version
id: published
run: echo "version=$(echo '${{ needs.release.outputs.publishedPackages }}' | jq -r '.[] | select(.name=="caravan-coordinator").version')" >> "$GITHUB_OUTPUT"
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Docker metadata
id: meta
uses: docker/metadata-action@v5
with:
images: caravanbitcoin/coordinator
tags: |
type=pep440,pattern={{version}},value=${{ steps.published.outputs.version }}
type=pep440,pattern={{major}}.{{minor}},value=${{ steps.published.outputs.version }}
type=sha
- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
context: .
file: ./apps/coordinator/Dockerfile
push: true
platforms: linux/amd64,linux/arm64
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}