Release from test #3
Workflow file for this run
This file contains 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: 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 | |
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/request-action@v2.x | |
# 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 }} |