Release to Docker Hub #2
This file contains hidden or 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 to Docker Hub | |
| on: | |
| workflow_dispatch: | |
| # No inputs - when you trigger, it releases | |
| permissions: | |
| contents: write # Push branches/tags | |
| jobs: | |
| release: | |
| name: Release | |
| runs-on: ubuntu-latest | |
| # Only allow running from develop branch | |
| if: github.ref == 'refs/heads/develop' | |
| steps: | |
| - uses: actions/create-github-app-token@v1 | |
| id: app-token | |
| with: | |
| app-id: ${{ secrets.APP_ID }} | |
| private-key: ${{ secrets.APP_PRIVATE_KEY }} | |
| - name: Checkout develop branch | |
| uses: actions/checkout@v4 | |
| with: | |
| ref: develop | |
| fetch-depth: 0 # Full history for merging | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '24' | |
| - name: Install dependencies | |
| run: yarn install --immutable | |
| - name: Build | |
| run: yarn build | |
| - name: Lint | |
| run: yarn lint | |
| - name: Test | |
| run: yarn test:unit | |
| - name: Apply release changes | |
| run: yarn applyReleaseChanges | |
| - name: Get version from package.json | |
| id: version | |
| run: | | |
| VERSION=$(node -p "require('./package.json').version") | |
| echo "version=$VERSION" >> $GITHUB_OUTPUT | |
| echo "Release version: $VERSION" | |
| - name: Configure git | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| - name: Commit changes if any | |
| run: | | |
| git add -A | |
| if git diff --staged --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "chore: release v${{ steps.version.outputs.version }}" | |
| fi | |
| - name: Push develop branch | |
| run: git push origin develop | |
| - name: Merge develop to master | |
| run: | | |
| git checkout master | |
| git merge develop --no-edit | |
| git push origin master | |
| - name: Create and push release tag | |
| continue-on-error: true | |
| run: | | |
| git tag "v${{ steps.version.outputs.version }}" | |
| git push origin "v${{ steps.version.outputs.version }}" | |
| - name: Docker login | |
| env: | |
| DOCKER_USER: ${{ secrets.DOCKER_USER }} | |
| DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} | |
| run: | | |
| docker login -u $DOCKER_USER -p $DOCKER_PASSWORD | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| with: | |
| install: true | |
| - name: Build and push Docker image | |
| run: | | |
| docker build --platform linux/arm64,linux/amd64 \ | |
| --tag furystack/stack-craft:v${{ steps.version.outputs.version }} \ | |
| --tag furystack/stack-craft:latest \ | |
| . --push |