Fix deps (#42) #54
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: | |
release: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write # needed to push tag | |
strategy: | |
matrix: | |
node-version: [18.14.2] | |
steps: | |
- name: Get repo with depth | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 # needed to calculate version | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
cache: npm | |
registry-url: 'https://registry.npmjs.org' | |
- name: 'Install dependencies' | |
run: npm ci | |
- name: 'Run build' | |
run: npm run build | |
# Setup necessary info to create tag | |
- name: Set version variable with v, for use in tag and release | |
run: 'echo "RELEASE_TAG=v$(npm run --silent sdk-version)" >> $GITHUB_ENV' | |
- name: Configure git username | |
run: git config user.name github-actions-bot | |
- name: Configure git user email | |
run: git config user.email noreply@vipps.no | |
# Create git tag | |
- name: Create Tag | |
run: git tag ${{ env.RELEASE_TAG }} -m ${{ env.RELEASE_TAG }} | |
- name: Publish Tag | |
run: git push --tags | |
# Create git release | |
- name: 'Create GitHub Release' | |
uses: 'actions/github-script@v6' | |
with: | |
github-token: '${{ secrets.GITHUB_TOKEN }}' | |
script: | | |
try { | |
const response = await github.rest.repos.createRelease({ | |
draft: false, | |
generate_release_notes: true, | |
name: process.env.RELEASE_TAG, | |
owner: context.repo.owner, | |
prerelease: false, | |
repo: context.repo.repo, | |
tag_name: process.env.RELEASE_TAG, | |
}); | |
core.exportVariable('RELEASE_ID', response.data.id); | |
core.exportVariable('RELEASE_UPLOAD_URL', response.data.upload_url); | |
} catch (error) { | |
core.setFailed(error.message); | |
} | |
# Pack Npm package | |
- name: Create NPM package | |
run: 'mkdir out && npm pack --pack-destination="./out"' | |
# Add Npm pack to Github Release Assets | |
- name: Upload to GitHub release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
TAG: ${{ env.RELEASE_TAG }} | |
run: | | |
gh release upload ${{ env.RELEASE_TAG }} out/* --clobber | |
# Publish Npm package | |
- name: Publish Npm package | |
run: npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_ACCESS_TOKEN }} |