Update README.md #34
This file contains hidden or 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: Build and Release | |
| on: | |
| push: | |
| branches: [ main ] | |
| pull_request: | |
| branches: [ main ] | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v3 | |
| with: | |
| node-version: 18 | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build | |
| run: | | |
| mkdir -p dist | |
| npm run build | |
| # Copy the built file to root for releases | |
| - name: Prepare release asset | |
| if: github.event_name == 'release' | |
| run: | | |
| cp dist/ember-mug-card.js ./ember-mug-card.js | |
| # Use GitHub CLI to upload asset | |
| - name: Upload release asset | |
| if: github.event_name == 'release' | |
| run: | | |
| # Install GitHub CLI | |
| curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg | |
| echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null | |
| sudo apt update | |
| sudo apt install gh | |
| # Get release tag | |
| TAG_NAME="${GITHUB_REF#refs/tags/}" | |
| # Authenticate with GITHUB_TOKEN | |
| echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token | |
| # Upload the file to the release | |
| gh release upload "$TAG_NAME" ember-mug-card.js --clobber | |
| # Get changelog content and update release notes | |
| CHANGELOG=$(cat CHANGELOG.md) | |
| gh release edit "$TAG_NAME" --notes "$CHANGELOG" |