diff --git a/.github/workflows/publish.yaml b/.github/workflows/publish.yaml index a4413154..4befbc3a 100644 --- a/.github/workflows/publish.yaml +++ b/.github/workflows/publish.yaml @@ -3,6 +3,8 @@ name: Publish run-name: Publish by @${{ github.actor }} on: + workflow_dispatch: + push: tags: - 'v0.*' @@ -15,7 +17,6 @@ env: jobs: config: name: Check GoReleaser config - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') runs-on: ubuntu-latest steps: - name: Checkout @@ -28,13 +29,12 @@ jobs: publish: name: "Publish provider" - if: github.event_name == 'push' && contains(github.ref, 'refs/tags/') needs: config runs-on: ubuntu-latest permissions: actions: read # Required to identify workflow run. checks: write # Required to add status summary. - contents: read # Required to checkout repository. + contents: write # Required to checkout repository. pull-requests: write # Required to add PR comment. steps: - name: Install needed tools @@ -81,15 +81,15 @@ jobs: gpg --import ~/private.key.pem rm ~/private.key.pem - - name: Run GoReleaser with SNAPSHOT - if: github.event_name == 'workflow_dispatch' - id: goreleaser - env: - GITHUB_TOKEN: ${{ env.FORGEJO_TOKEN }} - GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }} - uses: goreleaser/goreleaser-action@v7 - with: - args: release --skip publish --clean --snapshot +# - name: Run GoReleaser with SNAPSHOT +# if: github.event_name == 'workflow_dispatch' +# id: goreleaser +# env: +# GITHUB_TOKEN: ${{ env.FORGEJO_TOKEN }} +# GPG_FINGERPRINT: ${{ secrets.GPG_FINGERPRINT }} +# uses: goreleaser/goreleaser-action@v7 +# with: +# args: release --skip publish --clean --snapshot - name: Run GoReleaser if: github.event_name != 'workflow_dispatch' @@ -105,9 +105,14 @@ jobs: run: | echo "${{ secrets.PUBLIC_KEY_PEM }}" >public_key.pem - - name: Prepare provider directory structure + - name: Determine version + id: get_version run: | VERSION=$(jq -r .version < dist/metadata.json) + echo "version=${VERSIO)N}" >> "$GITHUB_OUTPUT" + + - name: Prepare provider directory structure + run: | go run generator/main.go \ publish \ --namespace=mhenselin \ @@ -116,7 +121,7 @@ jobs: --domain=tfregistry.sysops.stackit.rocks \ --gpgFingerprint="${{ secrets.GPG_FINGERPRINT }}" \ --gpgPubKeyFile=public_key.pem \ - --version=${VERSION} + --version=${{ steps.get_version.outputs.version }} - name: Prepare documentation nav file run: | @@ -141,6 +146,7 @@ jobs: run: | set -e ssh -o StrictHostKeyChecking=no ubuntu@${{ vars.DOCS_SERVER_IP }} 'rm -rf /srv/www/docs' - echo "${{ github.ref_name }}" >docs/_version.txt + echo "${{ steps.get_version.outputs.version }}" >docs/_version.txt + # echo "${{ github.ref_name }}" >docs/_version.txt scp -o StrictHostKeyChecking=no -r docs ubuntu@${{ vars.DOCS_SERVER_IP }}:/srv/www/ scp -o StrictHostKeyChecking=no nav.md ubuntu@${{ vars.DOCS_SERVER_IP }}:/srv/www/