Release #40
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: | |
| jobs: | |
| build: | |
| name: Upload Release Asset | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Set up JDK 8 | |
| uses: actions/setup-java@v4 | |
| with: | |
| java-version: '8' | |
| distribution: 'adopt' | |
| check-latest: false | |
| - name: Build with Maven | |
| run: mvn -B install -DskipTests | |
| - name: Create Tag | |
| run: | | |
| RELEASE_TAG=$(cat ./src/main/resources/.version) | |
| RELEASE_VER=${RELEASE_TAG#v} | |
| echo "RELEASE_TAG=$RELEASE_TAG" >> $GITHUB_ENV | |
| echo "RELEASE_VER=$RELEASE_VER" >> $GITHUB_ENV | |
| - name: Compute SHA256 | |
| id: sha | |
| run: | | |
| FILE=./target/redis-rdb-cli-release.tar.gz | |
| SHA256=$(shasum -a 256 "$FILE" | awk '{print $1}') | |
| echo "SHA256=$SHA256" >> $GITHUB_ENV | |
| - name: Update Homebrew Tap | |
| env: | |
| PAT: ${{ secrets.PAT }} | |
| run: | | |
| # Clone tap repo | |
| git clone https://x-access-token:${PAT}@github.com/leonchen83/homebrew-redis-rdb-cli.git | |
| cd homebrew-redis-rdb-cli | |
| FORMULA_FILE=Formula/redis-rdb-cli.rb | |
| # Update formula fields | |
| sed -i "s|url \".*\"|url \"https://github.com/leonchen83/redis-rdb-cli/releases/download/${RELEASE_TAG}/redis-rdb-cli-release.tar.gz\"|" $FORMULA_FILE | |
| sed -i "s|version \".*\"|version \"${RELEASE_VER}\"|" $FORMULA_FILE | |
| sed -i "s|sha256 \".*\"|sha256 \"${SHA256}\"|" $FORMULA_FILE | |
| # Commit & push | |
| git config user.name "github-actions" | |
| git config user.email "github-actions@users.noreply.github.com" | |
| git add $FORMULA_FILE | |
| git commit -m "Update redis-rdb-cli to ${RELEASE_VER}" | |
| git push origin main | |
| - name: Create Release | |
| id: create_release | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| allowUpdates: true | |
| artifacts: ./target/redis-rdb-cli-release.tar.gz,./target/redis-rdb-cli-release.zip | |
| tag: ${{ env.RELEASE_TAG }} | |
| name: ${{ env.RELEASE_TAG }} | |
| draft: false | |
| prerelease: false | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USER }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| id: buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Build and Push latest | |
| id: latest | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: ./ | |
| file: ./Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: | | |
| ${{ secrets.DOCKER_USER }}/${{ secrets.REPO }}:latest | |
| ${{ secrets.DOCKER_USER }}/${{ secrets.REPO }}:${{ env.RELEASE_TAG }} | |
| - name: Image digest | |
| run: echo ${{ steps.latest.outputs.digest }} |