Merge pull request #4 from gorrion-io/changeset-release/main #7
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"] | |
jobs: | |
setup: | |
runs-on: ubuntu-latest | |
outputs: | |
hasChangesets: ${{ steps.changesets.outputs.hasChangesets }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- name: Setup pnpm | |
uses: pnpm/[email protected] | |
with: | |
run_install: false | |
- name: Setup node | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
cache: "pnpm" | |
- name: Get pnpm store directory | |
id: pnpm-cache | |
shell: bash | |
run: | | |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
name: Setup pnpm cache | |
with: | |
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }} | |
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
restore-keys: | | |
${{ runner.os }}-pnpm-store- | |
- name: Install deps (with cache) | |
run: pnpm install | |
- name: Run generator | |
run: pnpm run generate-template | |
- uses: actions/upload-artifact@v4 | |
id: artifacts | |
name: Upload templates | |
with: | |
name: templates | |
path: | | |
./clickup-template.csv | |
./jira-template.csv | |
if-no-files-found: ignore | |
- name: Create Release Pull Request | |
id: changesets | |
uses: changesets/action@v1 | |
env: | |
GITHUB_TOKEN: ${{ secrets.GH_TOKEN }} | |
publish: | |
needs: [setup] | |
runs-on: ubuntu-latest | |
if: needs.setup.outputs.hasChangesets == 'false' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: templates | |
path: templates | |
- name: Configure git identity | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
- name: Get version from package.json | |
id: get_version | |
run: echo "::set-output name=version::$(node -p "require('./package.json').version")" | |
- name: Check if tag exists | |
run: | | |
if git rev-parse v${{ steps.get_version.outputs.version }} >/dev/null 2>&1; then | |
echo "Tag v${{ steps.get_version.outputs.version }} already exists" | |
fi | |
- name: Remove existing tag if exists | |
run: | | |
if git rev-parse v${{ steps.get_version.outputs.version }} >/dev/null 2>&1; then | |
git push --delete origin v${{ steps.get_version.outputs.version }} | |
git tag -d v${{ steps.get_version.outputs.version }} | |
fi | |
- name: Create tag | |
run: | | |
git tag -a v${{ steps.get_version.outputs.version }} -m "Version ${{ steps.get_version.outputs.version }}" | |
git push origin v${{ steps.get_version.outputs.version }} | |
- name: Create a Release | |
uses: ncipollo/release-action@v1 | |
with: | |
artifacts: ./templates/* | |
token: ${{ secrets.GH_TOKEN }} | |
name: Release v${{ steps.get_version.outputs.version }} | |
tag: v${{ steps.get_version.outputs.version }} | |
body: CHANGELOG.md |