chore: remove redundant always
flag on commit-step
#21
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 and Publish | |
on: [push] | |
env: | |
BRANCH_TAG: "${{ github.ref_name == 'main' && 'latest' || github.ref_name }}" | |
BRANCH: ${{ github.ref_name }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Install dependencies | |
run: npm ci | |
- name: Run lint | |
run: npm run lint | |
- name: Run tests | |
run: npm run test | |
release: | |
environment: ${{ github.ref_name == 'main' && 'Prod' || '' }} | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Generate token | |
if: ${{ github.ref_name == 'main' }} | |
id: generate_token | |
uses: tibdex/github-app-token@v2 | |
with: | |
app_id: ${{ vars.FUNDABOT_APP_ID }} | |
private_key: ${{ secrets.FUNDABOT_PRIVATE_KEY }} | |
- uses: actions/checkout@v3 | |
if: ${{ github.ref_name == 'main' }} | |
with: | |
token: ${{ steps.generate_token.outputs.token }} | |
- uses: actions/checkout@v3 | |
if: ${{ github.ref_name != 'main' }} | |
- name: Version bump | |
id: version | |
uses: phips28/gh-action-bump-version@v9.1.0 | |
with: | |
major-wording: ${{ env.BRANCH == 'main' && '[bump major]' || '[bump major --force]' }} | |
minor-wording: ${{ env.BRANCH == 'main' && '[bump minor]' || '[bump minor --force]' }} | |
patch-wording: ${{ null }} | |
rc-wording: ${{ null }} | |
default: "${{ env.BRANCH == 'main' && 'patch' || 'prerelease' }}" | |
preid: "${{ env.BRANCH }}" | |
skip-tag: "true" | |
skip-push: "true" | |
skip-commit: "true" | |
bump-policy: "ignore" | |
- name: Release | |
env: | |
VERSION: ${{ steps.version.outputs.newTag }} | |
run: | | |
if [ "${BRANCH}" != "main" ]; then PRERELEASE="-p"; fi | |
echo "Releasing version ${VERSION} on branch ${BRANCH}" | |
gh release create ${VERSION} --target ${BRANCH} --generate-notes ${PRERELEASE} | |
- name: Commit changes | |
env: | |
VERSION: ${{ steps.version.outputs.newTag }} | |
run: | | |
git config user.email "fundabot@fundwave.com" | |
git config user.name "fundabot" | |
git commit -am "CI: bumps oidc-client version to $VERSION" -m "[skip ci]" | |
git tag "v$VERSION" HEAD -m "CI: bumps version to $VERSION" | |
- name: Push changes | |
if: always() | |
run: git push --follow-tags --atomic --no-verify | |
publish-npmjs: | |
needs: release | |
environment: ${{ github.ref_name == 'main' && 'prod' || '' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- run: git pull origin ${{ github.ref }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
registry-url: https://registry.npmjs.org | |
- name: Install dependencies | |
run: npm ci | |
- name: Publish package | |
run: npm publish --tag $BRANCH_TAG --access public | |
env: | |
NODE_AUTH_TOKEN: ${{secrets.NPMJS_TOKEN}} | |
publish-gitlab: | |
needs: release | |
environment: ${{ github.ref_name == 'main' && 'prod' || '' }} | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- run: git pull origin ${{ github.ref }} | |
- name: Setup .npmrc file for publish | |
env: | |
GITLAB_TOKEN: ${{secrets.GITLAB_TOKEN}} | |
run: | | |
echo @fundwave:registry=https://gitlab.com/api/v4/projects/24877554/packages/npm/ >> ~/.npmrc | |
echo //gitlab.com/api/v4/projects/24877554/packages/npm/:_authToken=$GITLAB_TOKEN >> ~/.npmrc | |
- name: Install dependencies | |
run: npm ci | |
- name: Publish package | |
run: npm publish --tag $BRANCH_TAG |