|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - "main" |
| 8 | + |
| 9 | +jobs: |
| 10 | + release: |
| 11 | + runs-on: ubuntu-latest-l |
| 12 | + if: ${{ !contains(github.event.head_commit.message, 'chore(release)') }} |
| 13 | + permissions: |
| 14 | + contents: write # to be able to publish a GitHub release |
| 15 | + issues: write # to be able to comment on released issues |
| 16 | + pull-requests: write # to be able to comment on released pull requests |
| 17 | + |
| 18 | + steps: |
| 19 | + - name: Checkout |
| 20 | + uses: actions/checkout@v3 |
| 21 | + with: |
| 22 | + persist-credentials: false |
| 23 | + |
| 24 | + - name: Clear space to remove unused folders |
| 25 | + run: | |
| 26 | + rm -rf /usr/share/dotnet |
| 27 | + rm -rf /opt/ghc |
| 28 | + rm -rf "/usr/local/share/boost" |
| 29 | + rm -rf "$AGENT_TOOLSDIRECTORY" |
| 30 | +
|
| 31 | + - name: Set up QEMU |
| 32 | + uses: docker/setup-qemu-action@v3 |
| 33 | + |
| 34 | + - name: Set up Docker Buildx |
| 35 | + uses: docker/setup-buildx-action@v3 |
| 36 | + |
| 37 | + - name: Login to Docker Hub |
| 38 | + uses: docker/login-action@v3 |
| 39 | + with: |
| 40 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 41 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 42 | + |
| 43 | + - name: Update the ToC in the README.md |
| 44 | + run: npx markdown-toc README.md -i |
| 45 | + |
| 46 | + - name: Semantic release |
| 47 | + uses: codfish/semantic-release-action@v3 |
| 48 | + id: semanticrelease |
| 49 | + with: |
| 50 | + additional-packages: | |
| 51 | + ['@semantic-release/git', '@semantic-release/changelog'] |
| 52 | + env: |
| 53 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN_SEMANTIC_RELEASE }} |
| 54 | + |
| 55 | + - name: Set environment variables |
| 56 | + if: steps.semanticrelease.outputs.new-release-published == 'true' |
| 57 | + run: | |
| 58 | + echo "DOCKERHUB_REPO=${{ secrets.DOCKERHUB_REPO }}" >> $GITHUB_ENV |
| 59 | + echo "DOCKERHUB_IMG=${{ secrets.DOCKERHUB_IMG }}" >> $GITHUB_ENV |
| 60 | + echo "HUGGINGFACE_ACCESS_TOKEN=${{ secrets.HUGGINGFACE_ACCESS_TOKEN }}" >> $GITHUB_ENV |
| 61 | + echo "RELEASE_VERSION=${{ steps.semanticrelease.outputs.release-version }}" >> $GITHUB_ENV |
| 62 | +
|
| 63 | + - name: Build and push the images to Docker Hub |
| 64 | + if: steps.semanticrelease.outputs.new-release-published == 'true' |
| 65 | + uses: docker/bake-action@v2 |
| 66 | + with: |
| 67 | + push: true |
| 68 | + set: | |
| 69 | + *.args.DOCKERHUB_REPO=${{ env.DOCKERHUB_REPO }} |
| 70 | + *.args.DOCKERHUB_IMG=${{ env.DOCKERHUB_IMG }} |
| 71 | + *.args.RELEASE_VERSION=${{ env.RELEASE_VERSION }} |
| 72 | + *.args.HUGGINGFACE_ACCESS_TOKEN=${{ env.HUGGINGFACE_ACCESS_TOKEN }} |
| 73 | +
|
| 74 | + - name: Update description on Docker Hub |
| 75 | + if: steps.semanticrelease.outputs.new-release-published == 'true' |
| 76 | + uses: peter-evans/dockerhub-description@v3 |
| 77 | + with: |
| 78 | + username: ${{ secrets.DOCKERHUB_USERNAME }} |
| 79 | + password: ${{ secrets.DOCKERHUB_TOKEN }} |
| 80 | + repository: ${{ env.DOCKERHUB_REPO }}/${{ env.DOCKERHUB_IMG }} |
0 commit comments