Merge pull request #127 from boidushya/main #24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: release | |
| # release process: | |
| # | |
| # on main branch merge: | |
| # 1. Calculate next semantic version tag (autotag) | |
| # 2. Build and push Dockerfile.base (ghcr.io/planetscale/ghcommit-action) | |
| # 3. Update version tag in Dockerfile, commit change | |
| # 4. Create GitHub Release for the new version | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - action.yaml | |
| - '**.sh' | |
| - Dockerfile | |
| - Dockerfile.base | |
| workflow_dispatch: | |
| jobs: | |
| test: | |
| runs-on: ubuntu-latest | |
| if: > | |
| (github.event_name == 'push' && !contains(toJson(github.event.commits), '[ci skip]') && !contains(toJson(github.event.commits), '[skip ci]')) | |
| || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 | |
| - run: make lint | |
| - run: make test | |
| release: | |
| runs-on: ubuntu-latest | |
| needs: [test] | |
| permissions: | |
| contents: write | |
| packages: write | |
| steps: | |
| - name: checkout code with full history (unshallow) | |
| uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6 | |
| with: | |
| fetch-depth: 0 | |
| fetch-tags: true | |
| - name: Calculate new version with autotag | |
| run: | | |
| set -xeou pipefail | |
| curl -sL https://git.io/autotag-install | sh -s -- -b "${RUNNER_TEMP}/bin" | |
| new_version=$(${RUNNER_TEMP}/bin/autotag -n) | |
| echo "new_version=$new_version" >> $GITHUB_ENV | |
| - name: login to ghcr.io | |
| uses: docker/login-action@5e57cd118135c172c3672efd75eb46360885c0ef # v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| # setup qemu and buildx for cross-builds (arm64) | |
| - name: Set up QEMU (for arm64 builds) | |
| uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@e468171a9de216ec08956ac3ada2f0791b6bd435 # v3 | |
| - name: Build and push Dockerfile.base (ghcr.io/planetscale/ghcommit-action) | |
| run: | | |
| # build and push a multi-arch image: | |
| image="ghcr.io/planetscale/ghcommit-action:v${new_version}" | |
| docker buildx build \ | |
| -f Dockerfile.base \ | |
| --platform linux/amd64,linux/arm64 \ | |
| --output type=image,name=$image,oci-mediatypes=true,compression=zstd,push=true \ | |
| . | |
| - name: Update image version in Dockerfile | |
| run: | | |
| sed -i'' -Ee "s/ghcommit-action:v(.*)/ghcommit-action:v${new_version}/" Dockerfile | |
| - name: Commit changes | |
| uses: planetscale/ghcommit-action@343f41817a6a0f882f18bbc59fdd37f49452736f # v0.2.19 | |
| with: | |
| commit_message: "🤖 Bump version in Dockerfile" | |
| repo: ${{ github.repository }} | |
| branch: ${{ github.head_ref || github.ref_name }} | |
| env: | |
| GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | |
| - name: Create GitHub Release | |
| run: | | |
| gh release create "v${new_version}" --target main --title "v${new_version}" --generate-notes | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |