Merge pull request #609 from amplify-education/hosted-zone-filtering-fix #25
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: Test, Lint, Release and Publish | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
main: | |
name: Release and publish Node package | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install and test | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 16.x | |
registry-url: 'https://registry.npmjs.org' | |
- run: npm install | |
- run: npm run build | |
- run: npm run lint | |
- run: npm test | |
- name: Extract version | |
id: extract_version | |
uses: Saionaro/[email protected] | |
- name: Get latest tag | |
id: get_latest_tag | |
uses: actions-ecosystem/action-get-latest-tag@v1 | |
with: | |
initial_version: 'v${{ steps.extract_version.outputs.version }}' | |
- name: See if version changed | |
run: | | |
if [[ "v${{ steps.extract_version.outputs.version }}" == "${{ steps.get_latest_tag.outputs.tag }}" ]]; then | |
echo "VERSION_CHANGED=false" >> "$GITHUB_ENV" | |
else | |
echo "VERSION_CHANGED=true" >> "$GITHUB_ENV" | |
fi | |
- name: Create tag | |
uses: rickstaa/action-create-tag@v1 | |
if: env.VERSION_CHANGED == 'true' | |
with: | |
tag: "v${{ steps.extract_version.outputs.version }}" | |
- name: Create release | |
if: env.VERSION_CHANGED == 'true' | |
uses: softprops/action-gh-release@v1 | |
with: | |
tag_name: 'v${{ steps.extract_version.outputs.version }}' | |
generate_release_notes: true | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Publish new version | |
if: env.VERSION_CHANGED == 'true' | |
# Note: Setting NODE_AUTH_TOKEN as job|workspace wide env var won't work | |
# as it appears actions/setup-node sets own value | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npm publish --verbose |