Skip to content

Commit

Permalink
fix(release): update the release workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
Jamie-BitFlight committed Oct 4, 2023
1 parent 855acde commit c8726e3
Show file tree
Hide file tree
Showing 3 changed files with 165 additions and 12 deletions.
149 changes: 149 additions & 0 deletions .github/workflows/create_github_release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
name: Release Updated GitHub Action

on:
push:
tags:
- 'v*.*.*'

jobs:
release:
if: (!contains(github.event.head_commit.message, 'build(release)') && !contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci'))
name: Release GitHub Actions
runs-on: ubuntu-latest
permissions:
actions: write
contents: write
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
token: ${{ secrets.RELEASE_TOKEN }}

- uses: actions/setup-node@v3
with:
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
always-auth: true
cache: npm

- name: Configure PATH
run: |
mkdir -p "$HOME/.local/bin"
echo "$HOME/.local/bin" >> "${GITHUB_PATH}"
echo "HOME=$HOME" >> "${GITHUB_ENV}"
- uses: actions/cache@v3
if: always()
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: |
.yarn/cache
node_modules
${{env.HOME}}/.cache
${{env.HOME}}/.local
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{hashFiles('.github/workflows/release_action.yml')}}
restore-keys: |
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-${{hashFiles('.github/workflows/release_action.yml')}}
${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}-
${{ runner.os }}-yarn-
- name: Configure Git
run: |
git config --global user.email "${{github.event.pusher.email || '[email protected]'}}"
git config --global user.name "${{github.event.pusher.name || 'GitHub[bot]'}}"
git fetch --tags
git status --porcelain -u
- name: Release It
run: |
set -e
npx auto release -vv
stub_major="${GITHUB_TAG%%\.*}"
stub_major_minor="${GITHUB_TAG%\.*}"
git tag -d "${stub_major}" 2>/dev/null || true
git tag -d "${stub_major_minor}" 2>/dev/null || true
git tag -a "${stub_major}" -m "Release ${newtag}"
git tag -a "${stub_major_minor}" -m "Release ${newtag}"
git push -f --follow-tags --set-upstream origin $branch
git push -f --tags origin
# - name: Bump Package Version
# if: github.event_name == 'push' && steps.next_version.outputs.new_version != ''
# id: bump-yarn
# env:
# newtag: '${{ steps.next_version.outputs.new_version }}'
# run: |
# yarntag="$(jq -r '.version' package.json)"
# if [[ ${yarntag#v} != "${newtag#v}" ]]; then
# yarn version -i "${newtag#v}" || true
# yarn generate-docs
# yarn "lint:markdown:fix"
# yarn "lint:fix"
# yarn auto changelog \
# --email "${{github.event.pusher.email}}" \
# --name "${{github.event.pusher.name}}" \
# --baseBranch "${{ github.event.pull_request.base.ref || github.ref }}" \
# --prerelease
# git add .
# git commit -m "build(release): v${newtag#v}" --no-verify
# git push origin main || true
# fi
# echo ::set-output name=sha::$(git rev-parse HEAD)

# - name: Create Release Branch
# if: github.event_name == 'push'
# id: release-branch
# env:
# newtag: '${{ steps.next_version.outputs.version }}'
# run: |
# git switch -C gh-action --no-guess ${{ steps.bump-yarn.outputs.sha }}
# rm -rf __tests__ src node_modules .github
# rm -rf .husky .trunk .vscode .cspell.json
# rm -rf ./eslint* ./prettier* ./.lint* ./.markdown*
# rm -rf junit.xml README.example.md ./.tsconfig.json
# git add .
# git add -f dist
# git commit -m "build(release): v${newtag#v}"
# git push origin gh-action -u --force
# npx auto shipit --base-branch gh-actions -m 'docs: Update CHANGELOG.md [skip ci]' --name "${{github.event.pusher.name}}" --email "${{github.event.pusher.email}}"
# echo ::set-output name=sha::$(git rev-parse HEAD)
# - name: Bump version and push tag
# if: steps.bump.outputs.bump != ''
# id: tag_version
# uses: mathieudutour/[email protected]
# with:
# commit_sha: ${{ steps.release-branch.outputs.sha }}
# custom_tag: '${{ steps.next_version.outputs.new_version }}'
# github_token: ${{ secrets.RELEASE_TOKEN }}
# - name: Create a GitHub release
# if: steps.bump.outputs.bump != ''
# uses: ncipollo/release-action@v1
# with:
# tag: ${{ steps.tag_version.outputs.new_tag }}
# name: Release ${{ steps.tag_version.outputs.new_tag }}
# body: ${{ steps.tag_version.outputs.changelog }}
# artifacts: dist/index.cjs
# generateReleaseNotes: true
# token: ${{ secrets.RELEASE_TOKEN }}
# - name: Publish to NPM
# if: steps.bump.outputs.bump != ''
# run: |
# npm publish --no-package-lock --prefer-offline --no-audit --no-progress --no-bin-links --ignore-scripts --ignore-engines --ignore-platform
# - name: Update Label Tags
# if: steps.bump.outputs.bump != ''
# env:
# newtag: ${{ steps.tag_version.outputs.new_version }}
# run: |
# git fetch --tags
# stub_major="${newtag%%\.*}"
# stub_major_minor="${newtag%\.*}"
# git tag -f v${stub_major}
# git push -f origin v${stub_major}
# git tag v${stub_major_minor}
# git push -f origin v${stub_major_minor}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tag and Release Updated GitHub Action
name: Tag and Release Updated NPM Package

on:
push:
Expand All @@ -11,7 +11,7 @@ on:

jobs:
release:
if: (!contains(github.event.head_commit.message, 'build(release)') && !contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci'))
if: (!contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci') && !contains(github.event.head_commit.message, 'build(release)') && !contains(github.event.head_commit.message, 'ci skip') && !contains(github.event.head_commit.message, 'skip ci'))
name: Release GitHub Actions
runs-on: ubuntu-latest
permissions:
Expand All @@ -27,9 +27,12 @@ jobs:
token: ${{ secrets.RELEASE_TOKEN }}
ref: ${{ github.head_ref || github.ref }}

- name: Prepare repository
run: git fetch --unshallow --tags

- uses: actions/setup-node@v3
with:
node-version: '16.x'
node-version: '20.x'
registry-url: 'https://registry.npmjs.org'
always-auth: true
cache: npm
Expand Down Expand Up @@ -81,23 +84,24 @@ jobs:
git status --porcelain -u
git diff package.json
- name: Test
run: |
yarn test
yarn build:inputs
- name: Build
id: build
run: |
yarn run build
- name: Run tests
run: |
yarn run test
git status --porcelain -u
- name: Ship It
run: |
git status --porcelain -u
git add -f dist package.json && \
git commit -m "build(release): version $(jq -r '.version' package.json)" && \
git commit --allow-empty -m "build(release): version $(jq -r '.version' package.json)"
yarn auto shipit -vv && \
git tag -a "v$(jq -r '.version' package.json)" -m "build(release): version $(jq -r '.version' package.json)"
yarn auto shipit -vv
yarn postversion:manual
# - name: Bump Package Version
# if: github.event_name == 'push' && steps.next_version.outputs.new_version != ''
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push_code_linting.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ jobs:
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
- name: Build
- name: Install Deps
run: |
yarn install
- name: eslint
Expand Down

0 comments on commit c8726e3

Please sign in to comment.