Skip to content

update

update #19

Workflow file for this run

name: Release
on:
push:
branches:
- svelte-5-gitaction
env:
local_version: 0.0.0
npm_version: 0.0.0
change_version: false
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# - name: Setup node.js
# uses: actions/setup-node@v4
# with:
# node-version: '20'
# - name: Install dependencies
# run: npm install
# - name: Use linter
# run: npm run lint
# - name: Build mytril
# run: npm run build
prepublish:
runs-on: ubuntu-latest
needs: build
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Get version from package.json
id: get_version_local
run: |
LOCAL_VERSION=$(node -p "require('./package.json').version")
echo "$(node -p "require('./package.json').version")"
echo "local_version=$LOCAL_VERSION" >> $GITHUB_ENV
env:
local_version: $(node -p "require('./package.json').version")
- name: Check if version is insider
if: contains(env.local_version, 'insiders')
run: |
echo "Version contains 'insiders', skipping publication. ${{ env.local_version }}"
exit 1
- name: Authenticate to NPM
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc
- name: Get version from NPM
id: get_npm_version
run: |
PACKAGE_NAME="mytril"
NPM_VERSION=$(npm show $PACKAGE_NAME version || echo "0.0.0")
echo "npm_version=$NPM_VERSION" >> $GITHUB_ENV
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
npm_version: $(npm show $PACKAGE_NAME version || echo "0.0.0")
- name: Compare Diff
if: env.local_version != env.npm_version
run: |
echo "${{ env.local_version }}"
echo "${{ env.npm_version }}"
env:
change_version: false
- name: Compare Egal
if: env.local_version == env.npm_version
run: |
echo "${{ env.local_version }}"
echo "${{ env.npm_version }}"
env:
change_version: true
test:
runs-on: ubuntu-latest
needs: prepublish
steps:
- uses: actions/checkout@v4
- name: Authenticate to NPM
run: |
echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc
- name: Need change version
if: env.change_version
run: |
echo "${{ env.change_version }}"
version=$(npm version --no-git-tag-version)
echo "Generated version: $version"
echo "npm_version=$version" >> $GITHUB_ENV
- name: Compare Diff
run: |
echo "${{ env.local_version }}"
echo "${{ env.npm_version }}"
# - name: New prerelease version
# id: get_version_release
# run: |
# version=$(npm version prerelease --preid=latest --no-git-tag-version)
# echo "Generated version: $version"
# echo "version_release=${version}" >> $GITHUB_OUTPUT
# - name: Inspect the working tree
# run: |
# echo "Inspecting Git status and diff..."
# git status
# git diff
# - name: Commit & Push version change
# if: github.event_name == 'push'
# run: |
# git config --global user.name "github-actions[bot]"
# git config --global user.email "github-actions[bot]@users.noreply.github.com"
# git branch --show-current
# git commit -a -m "publish release - ${{ steps.get_version_release.outputs.version_release }}"
# git status
# git push
# publish:
# runs-on: ubuntu-latest
# needs: prepublish
# env:
# version_release: ${{ needs.prepublish.outputs.version_release }}
# steps:
# - uses: actions/checkout@v4
# - name: Setup node.js
# uses: actions/setup-node@v4
# with:
# node-version: '20'
# - name: Install dependencies
# run: npm install
# - name: New prerelease version
# run: npm version prerelease --preid=latest --no-git-tag-version
# - name: Authenticate to NPM
# run: |
# echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_AUTH_TOKEN }}" > ~/.npmrc
# - name: Build
# run: npm run build
# - name: Verify files
# run: npm pack --dry-run
# - name: Inspect the working tree
# run: echo "The current branch is ${{ env.version_release }}"
# - name: Publish to NPM
# run: |
# echo "Publishing version ${{ env.version_release }}"
# env:
# NODE_AUTH_TOKEN:
# ${{ secrets.NPM_AUTH_TOKEN }}
# #npm publish --tag insiders