-
Notifications
You must be signed in to change notification settings - Fork 30
162 lines (142 loc) · 5.09 KB
/
deploy.yml
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
# This is a copy-and-paste version of ci.yml but additionally creating a release
name: Release Artifacts
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
env:
JAVA_VERSION: '11'
NODE_VERSION: '16.x'
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@v4
with:
fetch-depth: 0
submodules: 'true'
- name: Set up JDK ${{ env.JAVA_VERSION }}
uses: actions/setup-java@v4
with:
java-version: ${{ env.JAVA_VERSION }}
distribution: 'zulu'
cache: 'sbt'
- name: Set up NodeJS ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- 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@v4
with:
name: effekt
path: bin/effekt
- name: Upload the npm package
uses: actions/upload-artifact@v4
with:
name: effekt-npm-package
path: effekt.tgz
release:
name: Create Release
runs-on: ubuntu-latest
needs: [build-jar]
steps:
- name: Download JAR artifact
uses: actions/download-artifact@v4
with:
name: effekt
path: distribution/
- name: Download npm package
uses: actions/download-artifact@v4
with:
name: effekt-npm-package
path: distribution/
# Generates nice release notes according to https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes
# We can also configure these down the road: https://docs.github.com/en/repositories/releasing-projects-on-github/automatically-generated-release-notes#configuring-automatically-generated-release-notes
- name: Generate Release Notes
id: generate_release_notes
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data } = await github.rest.repos.generateReleaseNotes({
owner: context.repo.owner,
repo: context.repo.repo,
tag_name: 'v${{ needs.build-jar.outputs.version }}',
});
core.setOutput('name', data.name);
core.setOutput('body', data.body);
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_name: Release v${{ needs.build-jar.outputs.version }}
tag_name: v${{ needs.build-jar.outputs.version }}
body: ${{ steps.generate_release_notes.outputs.body }}
draft: false
prerelease: false
- name: Upload jar file
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./distribution/effekt
asset_name: effekt.jar
asset_content_type: application/java-archive
- name: Upload npm package
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./distribution/effekt.tgz
asset_name: effekt.tgz
asset_content_type: application/gzip
publish-npm:
name: Publish NPM Package
runs-on: ubuntu-latest
needs: [build-jar, release]
steps:
- name: Download npm package
uses: actions/download-artifact@v4
with:
name: effekt-npm-package
- name: Set up NodeJS ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
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 }}