Skip to content

Commit c1c9538

Browse files
committed
ci: split out a relase action
1 parent 8553e4a commit c1c9538

File tree

2 files changed

+57
-31
lines changed

2 files changed

+57
-31
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: CI
22

33
on:
44
push:
5-
branches: [ "*.*.*" ]
5+
branches: [ "*.*.x" ]
66
pull_request:
77

88
env:
@@ -47,48 +47,19 @@ jobs:
4747
- run: cargo test
4848

4949
build:
50-
name: Build & upload an artifact
50+
name: Build & upload artifacts
5151
runs-on: windows-latest
5252
env:
5353
ARCHIVE_NAME: redscript-${{ github.ref_name }}.zip
54-
GIT_CLIFF_VERSION: 0.10.0
55-
CHANGELOG_FILE: ${{ github.workspace }}-CHANGES.md
5654

5755
steps:
5856
- uses: actions/checkout@v3
59-
with:
60-
fetch-depth: 0
6157
- uses: dtolnay/rust-toolchain@stable
6258
- uses: Swatinem/rust-cache@v2
6359

6460
- name: Build and package the mod archive
6561
run: .\resources\package.ps1 -stagingDir ${{ runner.temp }}/redscript-staging -archiveName ${{ env.ARCHIVE_NAME }}
6662

67-
- name: Install git-cliff
68-
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
69-
uses: Alex079/setup-custom-tool@v1
70-
with:
71-
archiveUrl: https://github.com/orhun/git-cliff/releases/download/v${{ env.GIT_CLIFF_VERSION }}/git-cliff-${{ env.GIT_CLIFF_VERSION }}-x86_64-pc-windows-msvc.zip
72-
archiveGlob: '*'
73-
toolName: git-cliff
74-
toolVersion: ${{ env.GIT_CLIFF_VERSION }}
75-
76-
- name: Generate a changelog
77-
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
78-
run: git cliff --current --strip header -o ${{ env.CHANGELOG_FILE }}
79-
80-
- name: Release
81-
uses: softprops/action-gh-release@v1
82-
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
83-
with:
84-
body_path: ${{ env.CHANGELOG_FILE }}
85-
files: |
86-
${{ env.MOD_ARTIFACT_PATH }}
87-
./target/release/redscript-cli.exe
88-
prerelease: ${{ contains(github.ref_name, '-RC') || contains(github.ref_name, '-M') }}
89-
env:
90-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
91-
9263
- name: Archive artifacts
9364
uses: actions/upload-artifact@v3
9465
if: ${{ !startsWith(github.ref, 'refs/tags/v') }}

.github/workflows/release.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags:
6+
- "v[0-9]+.[0-9]+.[0-9]+"
7+
8+
env:
9+
CARGO_INCREMENTAL: 0
10+
CARGO_TERM_COLOR: always
11+
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
12+
13+
jobs:
14+
release:
15+
name: Build & relase
16+
runs-on: windows-latest
17+
env:
18+
ARCHIVE_NAME: redscript-${{ github.ref_name }}.zip
19+
GIT_CLIFF_VERSION: 0.10.0
20+
CHANGELOG_FILE: ${{ github.workspace }}-CHANGES.md
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
with:
25+
fetch-depth: 0
26+
- uses: dtolnay/rust-toolchain@stable
27+
- uses: Swatinem/rust-cache@v2
28+
29+
- name: Build and package the mod archive
30+
run: .\resources\package.ps1 -stagingDir ${{ runner.temp }}/redscript-staging -archiveName ${{ env.ARCHIVE_NAME }}
31+
32+
- name: Install git-cliff
33+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
34+
uses: Alex079/setup-custom-tool@v1
35+
with:
36+
archiveUrl: https://github.com/orhun/git-cliff/releases/download/v${{ env.GIT_CLIFF_VERSION }}/git-cliff-${{ env.GIT_CLIFF_VERSION }}-x86_64-pc-windows-msvc.zip
37+
archiveGlob: '*'
38+
toolName: git-cliff
39+
toolVersion: ${{ env.GIT_CLIFF_VERSION }}
40+
41+
- name: Generate a changelog
42+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
43+
run: git cliff --current --strip header -o ${{ env.CHANGELOG_FILE }}
44+
45+
- name: Release
46+
uses: softprops/action-gh-release@v1
47+
if: ${{ startsWith(github.ref, 'refs/tags/v') }}
48+
with:
49+
body_path: ${{ env.CHANGELOG_FILE }}
50+
files: |
51+
${{ env.MOD_ARTIFACT_PATH }}
52+
./target/release/redscript-cli.exe
53+
prerelease: ${{ contains(github.ref_name, '-RC') || contains(github.ref_name, '-M') }}
54+
env:
55+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)