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

chore: upgrade release workflow #3524

Merged
merged 5 commits into from
Feb 13, 2025
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
81 changes: 22 additions & 59 deletions .github/workflows/publish-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,48 +51,6 @@ jobs:
if: inputs.skip_checks != true
run: |
make release-snapshot

check-changelog:
needs:
- check-branch
runs-on: ubuntu-22.04
steps:

- name: Checkout code
if: inputs.skip_checks != true
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Get latest commit SHA of Develop & Current Branch
if: inputs.skip_checks != true
id: get-develop-sha
run: |
SHA=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
https://api.github.com/repos/${{ github.repository }}/git/ref/heads/develop | jq -r '.object.sha')
echo "DEVELOP_SHA=${SHA}" >> ${GITHUB_ENV}
echo "CURRENT_BRANCH_SHA=${{ github.sha }}" >> ${GITHUB_ENV}

- name: Check for CHANGELOG.md changes
if: inputs.skip_checks != true
run: |
echo "Check the changelog has actually been updated from whats in develop"
echo "DEVELOP BRANCH SHA: ${DEVELOP_SHA}"
echo "CURRENT BRANCH SHA: ${CURRENT_BRANCH_SHA}"
CHANGELOG_DIFF=$(git diff ${DEVELOP_SHA}..${CURRENT_BRANCH_SHA} -- changelog.md)
echo "${CHANGELOG_DIFF}"
if [ -z "$CHANGELOG_DIFF" ]; then
echo "ERROR: No changes detected in CHANGELOG.md. Please update the changelog."
exit 1
else
echo "CHANGELOG.md has been updated."
fi

- name: Mark Job Complete Skipped
if: inputs.skip_checks == true
shell: bash
run: |
echo "continue"

publish-release:
permissions:
Expand All @@ -101,7 +59,6 @@ jobs:
attestations: write
if: inputs.skip_release != true
needs:
- check-changelog
- check-branch
- check-goreleaser
runs-on: ${{ vars.RELEASE_RUNNER }}
Expand All @@ -113,41 +70,42 @@ jobs:
- name: Change Log Release Notes.
id: release_notes
run: |
cat changelog.md > ${{ github.workspace }}-CHANGELOG.txt
cat ${{ github.workspace }}-CHANGELOG.txt
awk '/^## /{flag++} flag==1{print}' changelog.md > changelog-current.md
cat changelog-current.md

- name: Set Version
run: |
echo "GITHUB_TAG_MAJOR_VERSION=${{ inputs.version }}" >> ${GITHUB_ENV}
echo "GITHUB_TAG_VERSION=${{ inputs.version }}" >> ${GITHUB_ENV}

- name: Create Release Tag
shell: bash
run: |
git tag ${GITHUB_TAG_MAJOR_VERSION}
git tag ${GITHUB_TAG_VERSION}
create_tag=$(git push --tags || echo "tag exists")
if [[ $create_tag == "tag exists" ]]; then
echo "Delete existing tag to re-create"
git tag -d ${GITHUB_TAG_MAJOR_VERSION}
git push --delete origin ${GITHUB_TAG_MAJOR_VERSION}
git tag -d ${GITHUB_TAG_VERSION}
git push --delete origin ${GITHUB_TAG_VERSION}
echo "sleep for 5 seconds to let github catch up."
sleep 5
echo "Re-Create Tag."
git tag ${GITHUB_TAG_MAJOR_VERSION}
git tag ${GITHUB_TAG_VERSION}
git push --tags
fi

- name: Create GitHub Release
uses: softprops/action-gh-release@v1
uses: softprops/action-gh-release@v2.2.0
with:
prerelease: true
token: ${{ secrets.GITHUB_TOKEN }}
body_path: ${{ github.workspace }}-CHANGELOG.txt
tag_name: ${{ env.GITHUB_TAG_MAJOR_VERSION }}
body_path: changelog-current.md
tag_name: ${{ env.GITHUB_TAG_VERSION }}
generate_release_notes: false

- name: Publish Release Files
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GORELEASER_CURRENT_TAG: ${{ env.GITHUB_TAG_MAJOR_VERSION }}
GORELEASER_CURRENT_TAG: ${{ env.GITHUB_TAG_VERSION }}
run: |
touch .release-env
make release
Expand All @@ -162,13 +120,18 @@ jobs:
dist/checksums.txt

- name: Upload Attestation Bundle
env:
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
shell: bash
run: |
gh release upload ${{ env.GITHUB_TAG_MAJOR_VERSION }} ${{ steps.attestation.outputs.bundle-path }}
shell: bash
run: |
gh release upload ${{ env.GITHUB_TAG_VERSION }} ${{ steps.attestation.outputs.bundle-path }}

- name: Clean Up Workspace
if: always()
shell: bash
run: sudo rm -rf * || echo "failed to cleanup workspace please investigate"
run: sudo rm -rf * || echo "failed to cleanup workspace please investigate"

publish-typescript:
needs: publish-release
uses: ./.github/workflows/publish-typescript.yml
secrets: inherit
Original file line number Diff line number Diff line change
@@ -1,35 +1,36 @@
name: Publish Typescript to NPM
on:
workflow_dispatch:
release:
types: [created]
workflow_call:
jobs:
build:
publish:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Setup Node
uses: actions/setup-node@v2
uses: actions/setup-node@v4
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- name: Install buf
run: |
curl -sSL https://github.com/bufbuild/buf/releases/download/v1.28.1/buf-Linux-x86_64 -o /usr/local/bin/buf
curl -sSL https://github.com/bufbuild/buf/releases/download/v1.47.2/buf-Linux-x86_64 -o /usr/local/bin/buf
chmod +x /usr/local/bin/buf

- name: Generate
run: |
make typescript
make typescript

- name: Set Version
working-directory: typescript
run: |
version=$(cat ../app/setup_handlers.go | grep "const releaseVersion" | cut -d ' ' -f4 | tr -d '"')
npm version ${version}
npm version from-git --no-git-tag-version

- name: Publish package on NPM 📦
run: npm publish
Expand Down
File renamed without changes.
Loading