diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..206fdb3 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,58 @@ +name: Releases + +on: + release: + types: [published] + +jobs: + release: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: Set up JDK 1.8 + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: Grant execute permission for gradlew + run: chmod +x gradlew + + - name: Build with Gradle + run: ./gradlew build + + - name: Release + uses: fnkr/github-action-ghr@v1 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GHR_PATH: "build/libs/" + + - name: Generate Docker metadata + id: meta + uses: docker/metadata-action@v3 + with: + images: | + criteord/cassandra_exporter + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + flavor: | + latest=true + + - name: Login to Docker Hub + uses: docker/login-action@v1 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v1 + + - name: Build and push + uses: docker/build-push-action@v2 + with: + context: . + file: docker/Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml deleted file mode 100644 index a4b0092..0000000 --- a/.github/workflows/releases.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: Releases - -on: - push: - tags: - - '*' - -jobs: - release: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - - name: Grant execute permission for gradlew - run: chmod +x gradlew - - - name: Build with Gradle - run: ./gradlew build - - - uses: ncipollo/release-action@v1 - with: - artifacts: "build/libs/*.jar" - bodyFile: "" - token: ${{ secrets.GITHUB_TOKEN }} - - - name: Get release version - id: get_version - run: echo ::set-env name=RELEASE_VERSION::$(echo ${GITHUB_REF:10}) - - - name: Publish to Registry - uses: elgohr/Publish-Docker-Github-Action@2.14 - with: - name: criteord/cassandra_exporter - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - dockerfile: docker/Dockerfile - tags: "latest,${{ env.RELEASE_VERSION }}"