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

the release job updates versions, creates readme and release PR #528

Merged
merged 5 commits into from
Jan 20, 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
96 changes: 96 additions & 0 deletions .github/workflows/deploy-release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
name: Deployment

run-name: 'Release from ${{ github.ref_name }}'

on:
pull_request:
branches:
- test
types:
- closed

jobs:
version-and-tag:
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'release/')
runs-on: ubuntu-latest

outputs:
VERSION: ${{ steps.extract_version.outputs.VERSION }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Extract version from source branch name
id: extract_version
run: |
VERSION=${GITHUB_HEAD_REF#release/}
echo "VERSION=$VERSION" >> $GITHUB_ENV
echo "VERSION=$VERSION" >> $GITHUB_OUTPUT
echo "Source branch version: $VERSION"
# tag the commit with the version and push the tag
- name: Tag the commit with the version
run: |
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git tag -a $VERSION -m "Release version $VERSION"
- name: Push the tag to the repository
run: |
echo "Pushing tag $VERSION"
# git push origin "$VERSION" --follow-tags

publish-github:
runs-on: ubuntu-latest
needs: [ version-and-tag ]

permissions:
contents: write

env:
VERSION: ${{ needs.version-and-tag.outputs.VERSION }}

steps:
- name: Checkout repository
uses: actions/checkout@v3

- run: echo "Creating GitHub release for version ${{ env.VERSION }}"
# - name: Create GitHub Release
# uses: octokit/[email protected]
# id: create_release
# with:
# route: POST /repos/{owner}/{repo}/releases
# owner: ${{ github.repository_owner }}
# repo: ${{ github.event.repository.name }}
# tag_name: ${{ env.VERSION }}
# name: ${{ env.VERSION }}
# generate_release_notes: true
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-npm:
runs-on: ubuntu-latest

needs: [version-and-tag, publish-github]
env:
VERSION: ${{ needs.version-and-tag.outputs.VERSION }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ env.VERSION }}

# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- run: npm ci

- name: Publish swaggerhub-cli ${{ env.VERSION }} to npm
run: |
echo "Publishing version $VERSION to npm"
# npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
62 changes: 9 additions & 53 deletions .github/workflows/release-on-github.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,64 +33,20 @@ jobs:
- run: npm ci

- name: Bump version and regenerate README
id: create_tags
run: |
# https://github.com/orgs/community/discussions/26560
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
VERSION=$(npm version ${{inputs.type}} --no-git-tag-version)
npx oclif readme && node src/format-readme.js
git commit -am "Release for ${VERSION}"
git tag $VERSION
git checkout -b release/${VERSION}
echo "RELEASE_VERSION=${VERSION}" >> $GITHUB_OUTPUT
echo "Released version ${VERSION}" >> $GITHUB_STEP_SUMMARY
id: create_tags

- run: git push origin --follow-tags

publish-github:
runs-on: ubuntu-latest

needs: bump-version
permissions:
contents: write
env:
VERSION: ${{ needs.bump-version.outputs.RELEASE_VERSION }}

steps:
- name: Create GitHub Release
uses: octokit/[email protected]
id: create_release
with:
route: POST /repos/{owner}/{repo}/releases
owner: ${{ github.repository_owner }}
repo: ${{ github.event.repository.name }}
tag_name: ${{ env.VERSION }}
name: ${{ env.VERSION }}
generate_release_notes: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-npm:
runs-on: ubuntu-latest
echo "Release version ${VERSION} PR created" >> $GITHUB_STEP_SUMMARY

needs: [bump-version, publish-github]
env:
VERSION: ${{ needs.bump-version.outputs.RELEASE_VERSION }}

steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ env.VERSION }}

# Setup .npmrc file to publish to npm
- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'

- run: npm ci

- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Create release PR
run: |
git commit \
-am "Release of ${VERSION}" \
-m "[skip ci]"
git push origin --follow-tags
Loading