diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index 3006d69..46657ee 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -2,89 +2,66 @@ name: Release with goreleaser on: push: branches: - - "!*" + - "!*" tags: - - "v*.*.*" + - "v*.*.*" jobs: build: runs-on: ubuntu-latest name: goreleaser steps: - - name: Set up Go - uses: actions/setup-go@v3 - with: - go-version: 1.19 - id: go + - id: get_version + uses: battila7/get-version-action@v2 + - run: echo ${{ steps.get_version.outputs.version-without-v }} + - name: Set up Go + uses: actions/setup-go@v3 + with: + go-version: 1.19 + id: go - - name: Check out code into the Go module directory - uses: actions/checkout@v2 - with: - path: mqtt-mirror - fetch-depth: 0 + - name: Check out code into the Go module directory + uses: actions/checkout@v2 + with: + path: mqtt-mirror + fetch-depth: 0 - - name: Checkout helm package repository repo - uses: actions/checkout@v2 - with: - token: ${{ secrets.PAT }} - repository: 4nte/helm-charts - path: helm-charts - ref: master + - name: Checkout helm package repository repo + uses: actions/checkout@v2 + with: + token: ${{ secrets.PAT }} + repository: 4nte/helm-charts + path: helm-charts + ref: master - - name: Docker Login - if: success() && startsWith(github.ref, 'refs/tags/') - env: - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - run: | - echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin + - name: Docker Login + if: success() && startsWith(github.ref, 'refs/tags/') + env: + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + run: | + echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin - - name: goreleaser - uses: goreleaser/goreleaser-action@v3 - with: - args: release - workdir: ${{github.workspace}}/mqtt-mirror - env: - GITHUB_TOKEN: ${{ secrets.PAT }} + - name: goreleaser + uses: goreleaser/goreleaser-action@v3 + with: + args: release + workdir: ${{github.workspace}}/mqtt-mirror + env: + GITHUB_TOKEN: ${{ secrets.PAT }} + - name: Publish helm chart + uses: stefanprodan/helm-gh-pages@v1.4.1 + with: + token: ${{ secrets.PAT }} + repository: charts + chart_version: ${{ steps.get_version.outputs.version-without-v }} + app_version: ${{ steps.get_version.outputs.version-without-v }} - - - name: Create helm package - uses: stefanprodan/kube-tools@v1 - with: - helm: 2.17.0 - command: | - export SEMVER=${GITHUB_REF#refs/tags/v} - - echo "-- here --" - pwd - ls - - echo "-- GITHUB_WORKSPACE --" - ls $GITHUB_WORKSPACE - - echo "-- GITHUB_WORKSPACE/helm-charts--" - ls $GITHUB_WORKSPACE/helm-charts - - echo "-- GITHUB_WORKSPACE/mqtt-mirror--" - ls $GITHUB_WORKSPACE/mqtt-mirror - echo "-- Code repo ---" - helm init --client-only - mkdir -p $GITHUB_WORKSPACE/helm-charts/charts/mqtt-mirror - helm package $GITHUB_WORKSPACE/mqtt-mirror/chart/mqtt-mirror --destination $GITHUB_WORKSPACE/helm-charts/charts/mqtt-mirror --version $SEMVER - helm repo index $GITHUB_WORKSPACE/helm-charts --url https://4nte.github.io/helm-charts/ - - cd $GITHUB_WORKSPACE/helm-charts - echo "-- Helm repo ---" - ls - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git add . - git commit -m "release helm chart" -a - - - name: Push changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.PAT }} - repository: 4nte/helm-charts - directory: ${{github.workspace}}/helm-charts + - name: Push changes + uses: ad-m/github-push-action@master + with: + branch: master + github_token: ${{ secrets.PAT }} + repository: helm-charts + directory: ${{github.workspace}}/helm-charts