Fork of daniellemaywood.uk/gleam — Wasm codegen work
1name: release-nightly
2
3on:
4 schedule:
5 - cron: '45 0 * * *'
6
7env:
8 CARGO_TERM_COLOR: always
9 RUSTFLAGS: "-D warnings"
10
11jobs:
12 nightly-last-run:
13 runs-on: ubuntu-latest
14 name: Check latest commit
15 outputs:
16 should_run: ${{ steps.should_run.outputs.should_run }}
17 if: ${{ github.repository_owner == 'gleam-lang' }}
18 steps:
19 - uses: actions/checkout@v3
20 - name: print latest_commit
21 run: echo ${{ github.sha }}
22
23 - id: should_run
24 continue-on-error: true
25 name: check latest commit is less than a day
26 if: ${{ github.event_name == 'schedule' }}
27 run: test -z $(git rev-list --after="24 hours" ${{ github.sha }}) && echo "should_run=false" >> $GITHUB_OUTPUT
28
29 build-nightly-clean:
30 runs-on: ubuntu-latest
31 needs: [ nightly-last-run ]
32 if: ${{ github.repository_owner == 'gleam-lang' && needs.nightly-last-run.outputs.should_run != 'false' }}
33 steps:
34 - name: Delete old release assets
35 uses: mknejp/delete-release-assets@v1
36 with:
37 token: ${{ github.token }}
38 tag: nightly
39 fail-if-no-assets: false
40 fail-if-no-release: false
41 assets: |
42 *.zip
43 *.tar.gz
44 *.sha256
45 *.sha512
46
47 build-nightly:
48 name: build-release
49 runs-on: ${{ matrix.os }}
50 needs: [ build-nightly-clean ]
51 if: ${{ github.repository_owner == 'gleam-lang' }}
52 strategy:
53 matrix:
54 target:
55 - x86_64-unknown-linux-musl
56 - aarch64-unknown-linux-musl
57 - x86_64-apple-darwin
58 - aarch64-apple-darwin
59 - x86_64-pc-windows-msvc
60 toolchain: [stable]
61 include:
62 - os: ubuntu-latest
63 target: x86_64-unknown-linux-musl
64 use-cross: true
65 - os: ubuntu-latest
66 target: aarch64-unknown-linux-musl
67 use-cross: true
68 - os: macos-latest
69 target: x86_64-apple-darwin
70 use-cross: false
71 - os: macos-11
72 target: aarch64-apple-darwin
73 use-cross: false
74 - os: windows-latest
75 target: x86_64-pc-windows-msvc
76 use-cross: false
77 steps:
78 - name: Checkout repository
79 uses: actions/checkout@v3
80
81 - name: Update versions
82 shell: bash
83 run: |
84 ./bin/add-nightly-suffix-to-versions.sh
85
86 - name: Install Rust toolchain
87 uses: actions-rs/toolchain@v1
88 with:
89 toolchain: ${{ matrix.toolchain }}
90 target: ${{ matrix.target }}
91 override: true
92 default: true
93 profile: minimal
94
95 - name: Handle Rust dependencies caching
96 uses: Swatinem/rust-cache@v2
97 with:
98 key: v1-${{ matrix.target }}
99
100 - name: Build release binary
101 uses: actions-rs/cargo@v1
102 with:
103 command: build
104 args: --release --target ${{ matrix.target }}
105 use-cross: ${{ matrix.use-cross }}
106
107 - name: Build archive
108 shell: bash
109 run: |
110 VERSION=nightly
111 DAY=$(date +"%y%m%d")
112
113 if [ "${{ matrix.os }}" = "windows-latest" ]; then
114 ARCHIVE="gleam-$VERSION-${{ matrix.target }}.zip"
115 cp "target/${{ matrix.target }}/release/gleam.exe" "gleam.exe"
116 7z a "$ARCHIVE" "gleam.exe"
117 rm gleam.exe
118 else
119 ARCHIVE="gleam-$VERSION-${{ matrix.target }}.tar.gz"
120 cp "target/${{ matrix.target }}/release/gleam" "gleam"
121 tar -czvf "$ARCHIVE" "gleam"
122 rm gleam
123 fi
124
125 openssl dgst -r -sha256 -out "$ARCHIVE".sha256 "$ARCHIVE"
126 openssl dgst -r -sha512 -out "$ARCHIVE".sha512 "$ARCHIVE"
127 echo "ASSET=$ARCHIVE" >> $GITHUB_ENV
128 echo "DAY=$DAY" >> $GITHUB_ENV
129
130 - name: Ensure binary successfully boots
131 shell: bash
132 run: |
133 case "${{ matrix.target }}" in
134 x86_64-pc-windows-msvc)
135 7z x "$ASSET"
136 ./gleam.exe --version ;;
137 aarch64*)
138 echo "We cannot test an ARM binary on a AMD64 runner" ;;
139 *)
140 tar -xvzf "$ASSET"
141 ./gleam --version ;;
142 esac
143
144 - name: Upload release archive
145 shell: bash
146 run: |
147 for i in $(seq 5); do
148 hub release edit nightly \
149 --draft=false \
150 --prerelease \
151 --message=Nightly \
152 --message="nightly release for ${{ env.DAY }}" \
153 --attach="${{ env.ASSET }}" \
154 --attach="${{ env.ASSET }}.sha256" \
155 --attach="${{ env.ASSET }}.sha512" \
156 && break
157 done
158 env:
159 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
160 HUB_VERBOSE: 1
161
162 - name: Upload x86_64-unknown-linux-musl artifact
163 uses: actions/upload-artifact@v2
164 with:
165 name: gleam
166 path: target/${{ matrix.target }}/release/gleam
167 if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
168
169 build-nightly-container-images:
170 runs-on: ubuntu-latest
171 needs: [ build-nightly ]
172 if: ${{ github.repository_owner == 'gleam-lang' && needs.nightly-last-run.outputs.should_run != 'false' }}
173 strategy:
174 matrix:
175 base-image:
176 - erlang
177 - erlang-slim
178 - erlang-alpine
179 - elixir
180 - elixir-slim
181 - elixir-alpine
182 - node
183 - node-slim
184 - node-alpine
185
186 steps:
187 - name: Checkout repository
188 uses: actions/checkout@v2
189
190 - name: Download Gleam binary from previous job
191 uses: actions/download-artifact@v3
192 with:
193 name: gleam
194 path: ./
195
196 - name: Authenticate with GitHub container registry
197 uses: docker/login-action@v2
198 with:
199 registry: ghcr.io
200 username: lpil
201 password: ${{ secrets.CONTAINER_REGISTRY_PERSONAL_ACCESS_TOKEN }}
202
203 - name: Set up Docker Buildx
204 uses: docker/setup-buildx-action@v2
205
206 - name: Build and push
207 uses: docker/build-push-action@v3
208 with:
209 context: .
210 file: containers/${{ matrix.base-image }}.dockerfile
211 push: true
212 tags: ${{ steps.versions.outputs.container_tag }}
213 ghcr.io/${{ github.repository }}:nightly-${{ matrix.base-image }}
214 labels: |
215 org.opencontainers.image.title=gleam
216 org.opencontainers.image.url=https://gleam.run
217 org.opencontainers.image.source=https://github.com/gleam-lang/gleam
218 org.opencontainers.image.version=nightly-${{ matrix.base-image }}
219 org.opencontainers.image.licenses=Apache-2.0