diff --git a/.github/workflows/release-action-docker.yml b/.github/workflows/release-action-docker.yml deleted file mode 100644 index 1301ed0f0b3..00000000000 --- a/.github/workflows/release-action-docker.yml +++ /dev/null @@ -1,56 +0,0 @@ -name: Release Github action for CLI - -on: - release: - types: - - prereleased - -jobs: - release-action-yml: - name: Release github action for cli and update version in action.yml - runs-on: ubuntu-latest - env: - GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} - DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} - DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - with: - ref: master - - - name: Get version without v character - id: version - run: | - VERSION=${{github.event.release.tag_name}} - VERSION_WITHOUT_V=${VERSION:1} - echo "value=${VERSION_WITHOUT_V}" >> $GITHUB_OUTPUT - - name: Release to Docker - run: | - echo ${{env.DOCKER_PASSWORD}} | docker login -u ${{env.DOCKER_USERNAME}} --password-stdin - npm run action:docker:build - docker tag asyncapi/github-action-for-cli:latest asyncapi/github-action-for-cli:${{ steps.version.outputs.value }} - docker push asyncapi/github-action-for-cli:${{ steps.version.outputs.value }} - docker push asyncapi/github-action-for-cli:latest - - - name: Update action.yml with version - run: | - VERSION=${{ steps.version.outputs.value }} - sed "s/\\\${ version }/${VERSION}/g" action-template.yml > action.yml - - - name: Create branch - run: | - git checkout -b update-action-docker-version-${{ github.sha }} - - - name: Commit and push - run: | - git config --global user.name asyncapi-bot - git config --global user.email info@asyncapi.io - git add action.yml - git commit -m "chore(action): update docker version in action.yml" - git push https://${{ env.GITHUB_TOKEN }}@github.com/asyncapi/cli - - - name: Create PR - run: | - gh pr create --title "chore(action): update docker version in action.yml" --body "Updated docker version of github action in action.yml" --head "update-action-docker-version-${{ github.sha }}" diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index 21790e4bfb8..d3484654bac 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -5,7 +5,6 @@ on: - published jobs: - publish-docker: name: Generating Docker runs-on: ubuntu-latest @@ -56,3 +55,45 @@ jobs: pass: ${{ secrets.DOCKER_PASSWORD }} slug: asyncapi/cli description: CLI to work with your AsyncAPI files + + publish-action-docker: + name: Release github action for cli and update version in action.yml + runs-on: ubuntu-latest + env: + GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} + DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }} + DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }} + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + with: + ref: master + + - name: Get version without v character + id: version + run: | + VERSION=${{github.event.release.tag_name}} + VERSION_WITHOUT_V=${VERSION:1} + echo "value=${VERSION_WITHOUT_V}" >> $GITHUB_OUTPUT + + - name: Release to Docker + run: | + echo ${{env.DOCKER_PASSWORD}} | docker login -u ${{env.DOCKER_USERNAME}} --password-stdin + npm run action:docker:build + docker tag asyncapi/github-action-for-cli:latest asyncapi/github-action-for-cli:${{ steps.version.outputs.value }} + docker push asyncapi/github-action-for-cli:${{ steps.version.outputs.value }} + docker push asyncapi/github-action-for-cli:latest + + - name: Change directory to github-action + run: | + cd github-action/ + ls -la + + - uses: meeDamian/sync-readme@v1.0.6 + with: + user: ${{ env.DOCKER_USERNAME }} + pass: ${{ env.DOCKER_PASSWORD }} + slug: asyncapi/github-action-for-cli + description: Github action for AsyncAPI CLI + diff --git a/.releaserc b/.releaserc index 1ac05cb151a..4b73d827296 100644 --- a/.releaserc +++ b/.releaserc @@ -1,7 +1,7 @@ --- branches: - master -# by default release workflow reacts on push not only to master. +# by default release workflow reacts on push not only to master. #This is why out of the box sematic release is configured for all these branches - name: next-spec prerelease: true @@ -20,5 +20,7 @@ plugins: - preset: conventionalcommits - - "@semantic-release/release-notes-generator" - preset: conventionalcommits +- - "./github-action/lib/bump-action-version.js" + - preset: conventionalcommits - "@semantic-release/npm" - "@semantic-release/github" diff --git a/github-action/lib/bump-action-version.js b/github-action/lib/bump-action-version.js new file mode 100644 index 00000000000..eb4f7b76ca2 --- /dev/null +++ b/github-action/lib/bump-action-version.js @@ -0,0 +1,20 @@ +const fs = require('fs'); +const path = require('path'); + +module.exports = async (pluginConfig, context) => { + const { nextRelease } = context; + const version = nextRelease.version; + + const templatePath = path.resolve(__dirname, '../../', 'action-template.yml'); + const outputPath = path.resolve(__dirname, '../../', 'action.yml'); + + try { + const templateContent = fs.readFileSync(templatePath, 'utf8'); + const updatedContent = templateContent.replace(/\${ version }/g, version); + fs.writeFileSync(outputPath, updatedContent, 'utf8'); + console.log(`Updated action.yml with version ${version}`); + } catch (error) { + console.error('Error updating action.yml:', error); + throw error; + } +};