Change git tag suffix to something more unique #167
Workflow file for this run
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: Rebuild Bowtie Image | |
on: | |
workflow_dispatch: | |
pull_request: | |
push: | |
branches-ignore: | |
- "wip*" | |
env: | |
IMAGE_REGISTRY: ghcr.io/${{ github.repository_owner }} | |
concurrency: | |
group: images-${{ github.ref }} | |
cancel-in-progress: true | |
permissions: {} | |
jobs: | |
meta: | |
runs-on: ubuntu-latest | |
outputs: | |
latest-version: ${{ steps.version.outputs.value }} | |
steps: | |
- name: Install bowtie | |
uses: bowtie-json-schema/bowtie@main | |
- name: Compute implementation name | |
id: impl | |
env: | |
GH_REPOSITORY: ${{ github.repository }} | |
run: echo "name=$(echo ${GH_REPOSITORY} | awk -F '/' '{print $2}')" >> $GITHUB_OUTPUT | |
- name: Compute latest implementation version | |
id: version | |
env: | |
IMPL_NAME: ${{ steps.impl.outputs.name }} | |
run: | | |
version=$(bowtie info \ | |
--implementation ${IMPL_NAME} \ | |
--format json | jq -r '.version // empty') | |
echo "value=${version}" >> $GITHUB_OUTPUT | |
echo "Latest version: $version" | |
build: | |
needs: meta | |
permissions: | |
id-token: write | |
contents: read | |
attestations: write | |
packages: write | |
uses: ./.github/workflows/build-image.yml | |
with: | |
is-latest: ${{ github.ref == 'refs/heads/main' }} | |
publish-image: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }} | |
mark-previous-version: | |
needs: [build, meta, automerge] | |
runs-on: ubuntu-latest | |
if: | | |
( | |
(github.event_name == 'push' && github.ref == 'refs/heads/main') | |
|| (github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]') | |
) | |
&& needs.build.outputs.current-version != needs.meta.outputs.latest-version | |
&& !cancelled() | |
permissions: | |
contents: write | |
env: | |
VERSION: ${{ needs.meta.outputs.latest-version }} | |
COMMIT: ${{ github.event.pull_request.base.sha || github.event.before }} # either the PR base ref or previous commit in the branch | |
GH_REPOSITORY: ${{ github.repository }} | |
steps: | |
- name: Create a release for previous implementation version | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAG: harness-release-${{ env.VERSION }} | |
run: > | |
gh api | |
--method POST | |
-H "Accept: application/vnd.github+json" | |
-H "X-GitHub-Api-Version: 2022-11-28" | |
/repos/${GH_REPOSITORY}/releases | |
-f "tag_name=$TAG" | |
-f "target_commitish=$COMMIT" | |
-f "name=$VERSION" | |
-f "body=Automatic release for $VERSION" | |
-F "generate_release_notes=true" | |
automerge: | |
needs: build | |
runs-on: ubuntu-latest | |
if: (!cancelled() && github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && !contains(github.event.pull_request.labels.*.name, 'github_actions')) | |
permissions: | |
contents: write | |
pull-requests: write | |
steps: | |
- name: Automatically merge allowed PRs | |
run: gh pr merge --auto --merge "$PR_URL" | |
env: | |
PR_URL: ${{ github.event.pull_request.html_url }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |