|
| 1 | +name: Release |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + tags: |
| 6 | + - '*.*.*' |
| 7 | + |
| 8 | +jobs: |
| 9 | + release: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + contents: read |
| 13 | + packages: write |
| 14 | + |
| 15 | + steps: |
| 16 | + - name: Generate GitHub token |
| 17 | + uses: tibdex/github-app-token@3beb63f4bd073e61482598c45c71c1019b59b73a # v2 |
| 18 | + id: generate-github-token |
| 19 | + with: |
| 20 | + app_id: ${{ secrets.RELEASE_BOT_APP_ID }} |
| 21 | + private_key: ${{ secrets.RELEASE_BOT_PRIVATE_KEY }} |
| 22 | + |
| 23 | + - name: Checkout code |
| 24 | + uses: actions/checkout@v4 |
| 25 | + with: |
| 26 | + ref: main |
| 27 | + token: ${{ steps.generate-github-token.outputs.token }} |
| 28 | + fetch-tags: true |
| 29 | + |
| 30 | + - name: Bump version in plugin.yaml |
| 31 | + run: | |
| 32 | + VERSION=$(echo ${GITHUB_REF#refs/tags/}) |
| 33 | + sed -i "s/version:.*/version: $VERSION/" plugin.yaml |
| 34 | + git config --global user.name 'github-actions' |
| 35 | + git config --global user.email 'github-actions@github.com' |
| 36 | + git add plugin.yaml |
| 37 | + git commit -m "Bump version to $VERSION" |
| 38 | + git tag -d $VERSION |
| 39 | + git push --delete origin $VERSION |
| 40 | + git tag $VERSION |
| 41 | + git push origin HEAD:main --tags |
| 42 | + env: |
| 43 | + GH_TOKEN: '${{ steps.generate-github-token.outputs.token }}' |
| 44 | + |
| 45 | + |
| 46 | + - uses: ncipollo/release-action@v1 |
| 47 | + name: Create GitHub Release |
| 48 | + id: create_release |
| 49 | + with: |
| 50 | + tag: ${{ github.ref }} |
| 51 | + name: ${{ github.ref }} |
| 52 | + token: ${{ steps.generate-github-token.outputs.token }} |
| 53 | + |
| 54 | + - name: Login to GitHub Container Registry |
| 55 | + uses: docker/login-action@v3 |
| 56 | + with: |
| 57 | + registry: ghcr.io |
| 58 | + username: ${{ github.actor }} |
| 59 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + - name: Build and push |
| 62 | + uses: docker/build-push-action@v6 |
| 63 | + with: |
| 64 | + context: . |
| 65 | + push: true |
| 66 | + tags: ghcr.io/jessesimpson36/yamldiff:${{ github.ref_name }} |
0 commit comments