x3dom-pushed #2
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: Publish Dev Release | |
on: | |
repository_dispatch: | |
types: [x3dom-pushed] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
outputs: | |
build_number: ${{steps.build_number.outputs.BUILD_NUMBER}} | |
commit_date: ${{steps.commit_date.outputs.COMMIT_DATE}} | |
steps: | |
- name: Get App token | |
id: app_token | |
uses: getsentry/action-github-app-token@v3 | |
with: | |
app_id: ${{ secrets.APP_ID }} | |
private_key: ${{ secrets.PRIVATE_KEY }} | |
- name: Checkout Release | |
uses: actions/checkout@v4 | |
with: | |
repository: ${{ github.event.client_payload.repository }} | |
ref: ${{ github.event.client_payload.ref }} | |
token: ${{ steps.app_token.outputs.token }} | |
fetch-depth: 0 | |
- name: Get build number | |
id: build_number | |
run: echo "BUILD_NUMBER=$(git rev-list --count HEAD)" >> $GITHUB_OUTPUT | |
- name: Get commit date | |
id: commit_date | |
run: echo "COMMIT_DATE=$(git log -1 --format="%at" | xargs -I{} date -d @{} +%Y%m%d_%H%M%S)" >> $GITHUB_OUTPUT | |
- name: Setup Node | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Build release | |
run: | | |
npm install | |
npm run build | |
- name: Remove archive | |
run: find dist/ -type f -name '*.zip' -delete | |
- name: Upload Artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: x3dom-dist | |
path: dist/ | |
retention-days: 1 | |
update: | |
runs-on: ubuntu-latest | |
needs: build | |
outputs: | |
has_changed: ${{ steps.add_commit.outputs.committed }} | |
steps: | |
- name: Get App token | |
id: app_token | |
uses: getsentry/action-github-app-token@v3 | |
with: | |
app_id: ${{ secrets.APP_ID }} | |
private_key: ${{ secrets.PRIVATE_KEY }} | |
- name: Checkout current head | |
uses: actions/checkout@v4 | |
with: | |
token: ${{ steps.app_token.outputs.token }} | |
- name: Check if dist folder exists | |
id: check_dist | |
uses: andstor/file-existence-action@v3 | |
with: | |
files: "dist" | |
- name: Remove entire dist-folder | |
if: steps.check_dist.outputs.files_exists == 'true' | |
run: git rm -r dist/ | |
- name: Download Artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: x3dom-dist | |
path: dist/ | |
- name: Add and Commit | |
id: add_commit | |
uses: EndBug/add-and-commit@v9 | |
with: | |
add: 'dist/' | |
message: ${{ needs.build.outputs.commit_date }}_${{ needs.build.outputs.build_number }} | |
publish: | |
runs-on: ubuntu-latest | |
needs: [build,update] | |
steps: | |
- name: Get App token | |
id: app_token | |
uses: getsentry/action-github-app-token@v3 | |
with: | |
app_id: ${{ secrets.APP_ID }} | |
private_key: ${{ secrets.PRIVATE_KEY }} | |
- name: Checkout new head | |
if: needs.update.outputs.has_changed == 'true' | |
uses: actions/checkout@v4 | |
with: | |
ref: 'main' | |
token: ${{ steps.app_token.outputs.token }} | |
- name: Publish release | |
if: needs.update.outputs.has_changed == 'true' | |
uses: "ncipollo/release-action@v1" | |
with: | |
tag: ${{ needs.build.outputs.commit_date }}_${{ needs.build.outputs.build_number }} | |
token: "${{ steps.app_token.outputs.token }}" | |
prerelease: false | |
artifacts: dist/*.js | |
- name: Remove old releases | |
if: needs.update.outputs.has_changed == 'true' | |
uses: dev-drprasad/[email protected] | |
with: | |
keep_latest: 1 | |
delete_tags: true | |
env: | |
GITHUB_TOKEN: ${{ steps.app_token.outputs.token }} | |