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

ci: update release workflow #57

Merged
merged 1 commit into from
Oct 31, 2024
Merged
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
71 changes: 55 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
name: Build applications
runs-on: ubuntu-latest
permissions:
contents: write
contents: read
id-token: write
steps:
- uses: mato533/cicd-actions/setup-pnpm@main
Expand All @@ -31,19 +31,6 @@ jobs:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Generate changelog for the Release
env:
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pnpm run changelog -c cliff-github.toml -l
pnpm exec prettier --write CHANGELOG.md

- name: Create Release
env:
GIT_TAG: ${{ github.ref_name }}
run: gh release create "${GIT_TAG}" ./*.tgz --draft=false -t "${GIT_TAG}" -F CHANGELOG.md

coverage:
name: Upload the coverage
needs:
Expand All @@ -54,11 +41,63 @@ jobs:
with:
cache: 'pnpm'

- name: Run the coverage
run: pnpm run coverage
- name: Run tests with coverage
id: test
env:
TEST_RESULT: 'junit.xml'
run: |
pnpm exec vitest run --coverage --reporter=junit --outputFile="${TEST_RESULT}"
echo "file-name=${TEST_RESULT}" >>"${GITHUB_OUTPUT}"
echo "file-name=${TEST_RESULT}"

- uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/coverage-final.json
verbose: true

- name: Upload test results to Codecov
uses: codecov/test-results-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }}
file: ${{ steps.test.outputs.file-name }}

create-release:
name: Create Release
runs-on: ubuntu-latest
needs:
- build
permissions:
contents: write
steps:
- uses: mato533/cicd-actions/setup-pnpm@main
with:
fetch-depth: 0
cache: 'pnpm'

- name: Generate changelog
env:
GITHUB_REPO: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pnpm run changelog -c cliff-github.toml -l
pnpm exec prettier --write CHANGELOG.md

- name: Download tarball
id: download
run: |
APP_NAME="$(cat ./package.json |jq .name|sed -e 's/"//g'| head -n1)"
APP_VERSION="$(cat ./package.json |jq .version|sed -e 's/"//g'| head -n1)"
TAR_URL="$(pnpm view "${APP_NAME}@${APP_VERSION}" dist.tarball)"
TAR_NAME="${TAR_URL##*/}"
echo "URL: ${TAR_URL}"
curl -sS -OL "${TAR_URL}"
echo "file-name=${TAR_NAME}" >>"${GITHUB_OUTPUT}"
echo "file-name=${TAR_NAME}"
ls -l "${TAR_NAME}"

- name: Create Release
env:
GIT_TAG: ${{ github.ref_name }}
TAR_NAME: ${{ steps.download.outputs.file-name }}
run: gh release create "${GIT_TAG}" "${TAR_NAME}" --draft=false -t "${GIT_TAG}" -F CHANGELOG.md