Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

release without pre-release #174

Closed
wants to merge 1 commit into from
Closed
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
60 changes: 29 additions & 31 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
on:
release:
types:
- created
workflow_dispatch:
inputs:
version:
required: true

concurrency:
group: ${{ github.event.release.tag_name }}
Expand All @@ -11,45 +12,42 @@ permissions:
contents: read

jobs:
verify-prerelease:
runs-on: ubuntu-latest
steps:
- run: |
echo "we only publish pre-releases!" >&2
exit 1
if: ${{ ! github.event.release.prerelease }}

qa:
needs: verify-prerelease
if: ${{ github.event.release.prerelease }}
uses: ./.github/workflows/ci.yml
shellcheck:
uses: ./.github/workflows/shellcheck.yml

publish:
needs: qa
needs: [qa, shellcheck]
permissions:
contents: write
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: strip prerelease component
run: echo "v=${V%%-rc}" >> $GITHUB_OUTPUT
id: strip
env:
V: ${{ github.event.release.tag_name }}
- uses: teaxyz/setup@v0

- name: Convert pre-release to release
- name: determine previous version
id: previous
run: |
curl -fX PATCH \
-H "Authorization: Bearer ${{ github.token }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"draft": false, "prerelease": false, "make_latest": true, "tag_name": "${{ steps.strip.outputs.v }}"}' \
"https://api.github.com/repos/${{ github.repository }}/releases/${{ github.event.release.id }}"

# delete pre-release tag
- run: |
git push origin :${{ github.event.release.tag_name }}
git tag -d ${{ github.event.release.tag_name }}
versions="$(git tag | grep '^v[0-9]\+\.[0-9]\+\.[0-9]\+')"
v_latest="$(npx -- semver $versions | tail -n1)"
echo "version=$v_latest" >> $GITHUB_OUTPUT

- name: sanity
run:
tea semverator lt ${{ steps.previous.outputs.version }} ${{ github.event.inputs.version }}

- run: gh release create
${{ github.event.inputs.version }}
--latest
--generate-notes
--notes-start-tag=${{ steps.previous.outputs.version }}
env:
GH_TOKEN: ${{ github.token }}

# we need the new tag for the next step
- run: git tag ${{ steps.strip.outputs.v }}
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ V=$(git describe --tags --abbrev=0 --match "v[0-9]*.[0-9]*.[0-9]*")
V=$(tea semverator bump $V $PRIORITY)

git push origin main
tea gh release create "v$V"-rc --prerelease --generate-notes --title "v$V"

gh workflow run cd.yml --raw-field version="$V"
```


Expand Down