Create a new release and update latest #4
Workflow file for this run
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: Create a new release and update latest | ||
on: | ||
release: | ||
types: [created] | ||
jobs: | ||
build-and-push: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
- name: Enable Corepack | ||
run: | | ||
corepack enable | ||
corepack prepare [email protected] --activate | ||
- name: Install dependencies | ||
run: yarn install | ||
- name: Build and bundle | ||
run: | | ||
cd apps/agent | ||
yarn bundle | ||
- name: Rename bundle | ||
run: mv apps/agent/dist/*.tgz apps/agent/dist/agent-${{ github.event.release.tag_name }}.tgz | ||
- name: Upload Release Asset | ||
uses: actions/upload-release-asset@v1 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
with: | ||
upload_url: ${{ github.event.release.upload_url }} | ||
asset_path: ./apps/agent/dist/agent-${{ github.event.release.tag_name }}.tgz | ||
asset_name: agent-${{ github.event.release.tag_name }}.tgz | ||
asset_content_type: application/gzip | ||
- name: Copy asset for latest | ||
run: cp apps/agent/dist/agent-${{ github.event.release.tag_name }}.tgz apps/agent/dist/agent-latest.tgz | ||
- name: Update latest release | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
run: | | ||
# Delete existing 'latest' tag | ||
git push --delete origin latest || true | ||
# Create new 'latest' tag | ||
git tag -f latest ${{ github.sha }} | ||
git push -f origin latest | ||
# Get the upload URL for the 'latest' release | ||
upload_url=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \ | ||
"https://api.github.com/repos/${{ github.repository }}/releases/tags/latest" \ | ||
| jq -r '.upload_url' | sed 's/{?name,label}//g') | ||
# If 'latest' release doesn't exist, create it | ||
if [ "$upload_url" = "null" ]; then | ||
response=$(curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \ | ||
-d '{"tag_name": "latest", "name": "Latest Release", "body": "This is always the latest release"}' \ | ||
"https://api.github.com/repos/${{ github.repository }}/releases") | ||
upload_url=$(echo "$response" | jq -r '.upload_url' | sed 's/{?name,label}//g') | ||
fi | ||
# Upload the asset to the 'latest' release | ||
curl -s -X POST -H "Authorization: token $GITHUB_TOKEN" \ | ||
-H "Content-Type: application/gzip" \ | ||
--data-binary @apps/agent/dist/agent-latest.tgz \ | ||
"${upload_url}?name=agent-latest.tgz" | ||
publish-to-npm: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: '20' | ||
- name: Enable Corepack | ||
run: | | ||
corepack enable | ||
corepack prepare [email protected] --activate | ||
- name: Publish to NPM | ||
run: npm ci | ||
run: npm run build | ||
Check failure on line 93 in .github/workflows/release.yaml GitHub Actions / Create a new release and update latestInvalid workflow file
|
||
run: npm publish | ||