-
Notifications
You must be signed in to change notification settings - Fork 43
128 lines (110 loc) · 3.63 KB
/
deploy.yml
File metadata and controls
128 lines (110 loc) · 3.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: Release Artifacts
permissions:
id-token: write
on:
push:
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
workflow_run:
workflows: ["Create Version and Tag"] # 'autorelease.yml'
types:
- completed
jobs:
build-jar:
name: Build and assemble the Effekt compiler
runs-on: ubuntu-latest
if: >
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')) ||
(github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
outputs:
version: ${{ steps.get_version.outputs.VERSION }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
submodules: 'true'
- uses: ./.github/actions/setup-effekt
- name: Get the version
id: get_version
run: |
if [ "${{ github.event_name }}" = "push" ]; then
echo "VERSION=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
elif [ "${{ github.event_name }}" = "workflow_run" ]; then
# For workflow_run event, we need to fetch the tag created in the previous workflow
git fetch --tags
LATEST_TAG=$(git describe --tags --abbrev=0)
echo "VERSION=${LATEST_TAG#v}" >> $GITHUB_OUTPUT
else
echo "Unsupported event type: ${{ github.event_name }}"
exit 1
fi
- name: Assemble jar file
run: sbt clean deploy
- name: Generate npm package
run: mv $(npm pack) effekt.tgz
- name: Upload Effekt binary
uses: actions/upload-artifact@v7
with:
name: effekt
path: bin/effekt
- name: Upload the npm package
uses: actions/upload-artifact@v7
with:
name: effekt-npm-package
path: effekt.tgz
release:
name: Create Release
runs-on: ubuntu-latest
needs: [build-jar]
steps:
# Login as a GitHub App in order to bypass GitHub's rules about automatic releases
- name: Get GitHub App token
uses: actions/create-github-app-token@v2
id: app-token
with:
app-id: ${{ secrets.EFFEKT_UPDATER_GH_APP_ID }}
private-key: ${{ secrets.EFFEKT_UPDATER_GH_CREDENTIALS_TOKEN }}
- name: Checkout code with token
uses: actions/checkout@v6
with:
submodules: 'true'
token: ${{ steps.app-token.outputs.token }}
- name: Download JAR artifact
uses: actions/download-artifact@v8
with:
name: effekt
path: distribution/
- name: Download npm package
uses: actions/download-artifact@v8
with:
name: effekt-npm-package
path: distribution/
- name: Create Release and Upload Assets
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
TAG: v${{ needs.build-jar.outputs.version }}
run: |
gh release create "$TAG" \
-t "Release $TAG" \
--verify-tag \
--generate-notes \
"./distribution/effekt#effekt.jar" \
"./distribution/effekt.tgz#effekt.tgz"
publish-npm:
name: Publish NPM Package
runs-on: ubuntu-latest
needs: [build-jar, release]
steps:
- name: Download npm package
uses: actions/download-artifact@v8
with:
name: effekt-npm-package
- name: Set up NodeJS ${{ env.NODE_VERSION }}
uses: actions/setup-node@v6
with:
node-version: ${{ env.NODE_VERSION }}
registry-url: 'https://registry.npmjs.org'
- name: Publish to NPM as @effekt-lang/effekt
run: npm publish effekt.tgz --provenance --access public
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}