Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 71 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
# yamllint disable rule:line-length
---
name: Release
name: Release TEST

on:
workflow_dispatch:
inputs:
tag:
description: Release tag (vX.Y.Z)
required: true
draft:
description: Dry run mode (true/false)
required: false
default: !!str true
prerelease:
description: Mark the release as a prerelease (true/false)
required: false
default: !!str true
push:
tags:
- v*.*.*
Expand All @@ -12,16 +25,70 @@ permissions:

concurrency:
group: release
cancel-in-progress: true

jobs:
create-release:
release:
permissions:
contents: write
runs-on: ubuntu-latest

steps:
- name: Clone the repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
uses: actions/checkout@2e5b7cfdf3b7c29bfa124b5f44ea66c2ba98d1a30eae32b2d6e74c23f44ef3d4 # v4.1.0

- id: version_source
name: Determine version source
run: |
if [[ '${{ github.event_name }}' == workflow_dispatch ]]; then
echo 'release_tag=${{ github.event.inputs.tag }}' >>"${GITHUB_OUTPUT}"
else
echo "release_tag=${GITHUB_REF_NAME}" >>"${GITHUB_OUTPUT}"
fi

- id: extract_version
name: Extract version from tag
run: |
version='${{ steps.version_source.outputs.release_tag }}'
version="${version#v}"
major_version="${version%%.*}"
echo "version=${version}" >>"${GITHUB_OUTPUT}"
echo "major_version=${major_version}" >>"${GITHUB_OUTPUT}"

- name: Update README.md version string
run: |
sed -i -E "s@(uses: .*/github-action-markdown-cli@)v[0-9]+\.[0-9]+\.[0-9]+@\1v${{ steps.extract_version.outputs.version }}@" README.md

- name: Update package.json version field
run: |
jq --arg v '${{ steps.extract_version.outputs.version }}' '.version = $v' package.json >package.json.tmp &&
mv package.json.tmp package.json

- name: Commit files if changed
run: |
git config user.name '${{ github.actor }}'
git config user.email '${{ github.actor }}@users.noreply.github.com'
git add README.md package.json
git commit -m 'Update version to v${{ steps.extract_version.outputs.version }}' || echo 'No changes to commit'
git push origin '${{ github.event.repository.default_branch }}'

- if: github.event_name != 'workflow_dispatch' || github.event.inputs.draft != 'true'
name: Conditionally move version tag forward
run: |
git tag --force '${{ steps.version_source.outputs.release_tag }}' HEAD
git push origin '${{ steps.version_source.outputs.release_tag }}' --force

- name: Create the release
uses: softprops/action-gh-release@72f2c25fcb47643c292f7107632f7a47c1df5cd8 # v2.3.2
run: |
args=(--fail-on-no-commits --notes-from-tag) # TODO: --verify-tag
[[ '${{ github.event.inputs.draft }}' == true ]] && args+=(--draft)
[[ '${{ github.event.inputs.prerelease }}' == true ]] && args+=(--prerelease)
gh release create '${{ steps.version_source.outputs.release_tag }}' "${args[@]}"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- if: github.event_name != 'workflow_dispatch' || github.event.inputs.draft != 'true'
name: Conditionally move major version tag
run: |-
git tag --force 'v${{ steps.extract_version.outputs.major_version }}' "${GITHUB_SHA}"
git push origin 'v${{ steps.extract_version.outputs.major_version }}' --force
24 changes: 0 additions & 24 deletions .github/workflows/versioning.yml

This file was deleted.

Loading