-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
name: Release | ||
|
||
on: | ||
push: | ||
branches: | ||
- svelte-5-gitaction | ||
|
||
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 | ||
outputs: | ||
local_version: ${{ steps.get_version_local.outputs.local_version }} | ||
version_release: ${{ steps.get_version_release.outputs.version_release }} | ||
|
||
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 "Local version: $LOCAL_VERSION" | ||
echo "local_version=$LOCAL_VERSION" >> $GITHUB_ENV | ||
- name: Check if version is insider | ||
if: contains(${{ steps.get_version_local.outputs.local_version }}, 'insiders') | ||
run: | | ||
echo "Version contains 'insiders', skipping publication." | ||
exit 1 | ||
- 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 |