test: try to fix ci tests #539
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: Release | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
types: | |
- opened | |
- synchronize | |
- reopened | |
- labeled | |
permissions: | |
pull-requests: write | |
contents: write | |
jobs: | |
release: | |
name: Release | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm | |
- name: Install Dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Create Release Pull Request or Publish to npm | |
id: changesets | |
uses: changesets/action@v1 | |
with: | |
title: 'chore(release): new version' | |
commit: 'chore(release): new version' | |
publish: pnpm release | |
version: pnpm changeset-version | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_PUBLISH }} | |
- name: Get current package version | |
id: get_version | |
run: echo "CURRENT_PACKAGE_VERSION=$(node -p "require('./packages/core/package.json').version")" >> $GITHUB_ENV | |
- name: Create Github Release | |
if: "startsWith(github.event.head_commit.message, 'chore(release): new version')" | |
uses: softprops/action-gh-release@v2 | |
with: | |
tag_name: v${{ env.CURRENT_PACKAGE_VERSION }} | |
release-unstable: | |
name: Release Unstable | |
runs-on: ubuntu-latest | |
if: "always() && (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == 'openwallet-foundation/credo-ts') || (github.event_name == 'push' && !startsWith(github.event.head_commit.message, 'chore(release): new version'))" | |
steps: | |
- uses: snnaplab/get-labels-action@v1 | |
if: github.event_name == 'pull_request' | |
# exit if pull request and no alpha-release tag | |
- if: github.event_name == 'pull_request' && !contains(fromJSON(env.LABELS), 'alpha-release') | |
run: exit 0 | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
cache: pnpm | |
- name: Install Dependencies | |
run: pnpm install --frozen-lockfile | |
- name: Creating .npmrc | |
run: | | |
cat << EOF > ".npmrc" | |
//registry.npmjs.org/:_authToken=$NPM_TOKEN | |
EOF | |
env: | |
NPM_TOKEN: ${{ secrets.NPM_PUBLISH }} | |
- name: Create unstable release | |
env: | |
TAG: ${{ github.event_name == 'push' && 'alpha' || format('pr-{0}', github.event.number) }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
NPM_TOKEN: ${{ secrets.NPM_PUBLISH }} | |
run: | | |
# this ensures there's always a patch release created | |
cat << 'EOF' > .changeset/snapshot-template-changeset.md | |
--- | |
'@credo-ts/core': patch | |
--- | |
snapshot release | |
EOF | |
pnpm changeset version --snapshot ${{ env.TAG }} | |
pnpm build | |
pnpm changeset publish --tag ${{ env.TAG }} | |
CURRENT_PACKAGE_VERSION=$(node -p "require('./packages/core/package.json').version") | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git tag v$CURRENT_PACKAGE_VERSION | |
git push origin v$CURRENT_PACKAGE_VERSION --no-verify |