Release #7
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 | |
| on: | |
| workflow_dispatch: | |
| env: | |
| JAVA_VERSION: 21 | |
| jobs: | |
| release: | |
| permissions: | |
| contents: write | |
| packages: write | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Generate GitHub App Token | |
| id: app-token | |
| uses: actions/create-github-app-token@v1 | |
| with: | |
| app-id: ${{ secrets.BOT_APP_ID }} | |
| private-key: ${{ secrets.BOT_PRIVATE_KEY }} | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ steps.app-token.outputs.token }} | |
| - name: Set up JDK ${{ env.JAVA_VERSION }} | |
| uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: ${{ env.JAVA_VERSION }} | |
| cache: 'gradle' | |
| - name: Switch to release | |
| run: | | |
| ./gradlew switchToRelease | |
| - name: Build uber-jar | |
| run: ./gradlew build -Dquarkus.package.jar.type=uber-jar | |
| - name: Commit changes | |
| shell: bash | |
| run: | | |
| VERSION=$(grep "switchBotMcpServerVersion=" gradle.properties | cut -d'=' -f2) | |
| git config user.name "sharplab-bot" | |
| git config user.email "actions@github.com" | |
| git add . | |
| git commit --allow-empty -m "Release ${VERSION}" | |
| - name: Push commit | |
| shell: bash | |
| run: | | |
| git fetch | |
| git rebase origin/master | |
| git push | |
| - name: Tag commit | |
| id: tag_commit | |
| shell: bash | |
| run: | | |
| VERSION=$(grep "switchBotMcpServerVersion=" gradle.properties | cut -d'=' -f2) | |
| TAG="${VERSION}.RELEASE" | |
| git tag "${TAG}" | |
| echo "release_tag=${TAG}" >> $GITHUB_OUTPUT | |
| - name: Push tag | |
| shell: bash | |
| run: | | |
| git push origin "${{ steps.tag_commit.outputs.release_tag }}" | |
| - name: Create GitHub Release | |
| id: create_release | |
| uses: actions/create-release@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| tag_name: ${{ steps.tag_commit.outputs.release_tag }} | |
| release_name: Release ${{ steps.tag_commit.outputs.release_tag }} | |
| draft: false | |
| prerelease: false | |
| - name: Upload Release Asset | |
| uses: actions/upload-release-asset@v1 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| upload_url: ${{ steps.create_release.outputs.upload_url }} | |
| asset_path: ./switchbot-mcp-server/build/switchbot-mcp-server.jar | |
| asset_name: switchbot-mcp-server.jar | |
| asset_content_type: application/java-archive | |
| - name: Log in to the GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Log in to Quay.io | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: quay.io | |
| username: ${{ secrets.QUAY_BOT_USERNAME }} | |
| password: ${{ secrets.QUAY_BOT_TOKEN }} | |
| - name: Extract metadata (tags, labels) for Docker | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: | | |
| ghcr.io/${{ github.repository }} | |
| quay.io/sharplab/switchbot-mcp-server | |
| tags: | | |
| type=raw,value=${{ steps.tag_commit.outputs.release_tag }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./switchbot-mcp-server/src/main/docker/Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} |