-
Notifications
You must be signed in to change notification settings - Fork 2
131 lines (112 loc) · 5.03 KB
/
release.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
name: Release Actions
on:
workflow_dispatch:
inputs:
bump:
description: "Bump"
required: true
default: 'patch'
type: choice
options:
- major
- minor
- patch
defaults:
run:
# Setting an explicit bash shell ensures GitHub Actions enables pipefail mode too,
# ratherthan only error on exit (improving failure UX when pipes are used). See:
# https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsshell
shell: bash
env:
CARGO_TERM_COLOR: always
jobs:
prepare:
name: Release
runs-on: pub-hk-ubuntu-22.04-small
steps:
- name: Get token for GH application (Linguist)
uses: heroku/use-app-token-action@main
id: generate-token
with:
app_id: ${{ vars.LINGUIST_GH_APP_ID }}
private_key: ${{ secrets.LINGUIST_GH_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v4
with:
# Using the GH application token here will configure the local git config for this repo with credentials
# that can be used to make signed commits that are attributed to the GH application user
token: ${{ steps.generate-token.outputs.app_token }}
# This will ensure commits made from this workflow are attributed to the GH application user
- name: Configure git
run: |
git config --global user.name ${{ vars.LINGUIST_GH_APP_USERNAME }}
git config --global user.email ${{ vars.LINGUIST_GH_APP_EMAIL }}
- name: Update Rust toolchain
run: rustup update
- name: Rust cache
uses: Swatinem/[email protected]
- name: Install cargo-bump
run: cargo install cargo-bump
- name: Get previous release version
id: previous-version
run: echo "value=$(gh release view --json tagName --jq '.tagName' | sed 's/^v//')" >> $GITHUB_OUTPUT
env:
GH_TOKEN: ${{ steps.generate-token.outputs.app_token }}
- name: Bump version
run: |
cargo bump ${{ steps.previous-version.outputs.value }}
cargo bump ${{ inputs.bump }}
- name: Build
run: cargo build --release
- name: Get release metadata
id: metadata
run: |
echo "name=$(cargo metadata --format-version=1 --no-deps | jq --exit-status -r '.packages[-1].targets[-1].name')" >> $GITHUB_OUTPUT
echo "version=$(cargo metadata --format-version=1 --no-deps | jq --exit-status -r '.packages[-1].version')" >> $GITHUB_OUTPUT
- name: Package binary
id: package-binary
run: |
ASSET_PATH=${{ runner.temp }}/${{ steps.metadata.outputs.name }}.tar.gz
tar -czf "${ASSET_PATH}" -C ./target/release ${{ steps.metadata.outputs.name }}
echo "path=${ASSET_PATH}" >> $GITHUB_OUTPUT
- name: Update actions/install-languages-cli/action.yml
run: |
yq -i '
.inputs.download_url.default = "https://github.com/${{ github.repository }}/releases/download/v${{ steps.metadata.outputs.version }}/${{ steps.metadata.outputs.name }}.tar.gz"
' .github/actions/install-languages-cli/action.yml
- name: Update workflows/_buildpacks-prepare-release.yml
run: |
yq -i '
(.jobs[].steps[] |
select(.uses == "${{ github.repository }}/.github/actions/install-languages-cli@main") |
.uses
) = "${{ github.repository }}/.github/actions/install-languages-cli@v${{ steps.metadata.outputs.version }}"
' .github/workflows/_buildpacks-prepare-release.yml
- name: Update workflows/_buildpacks-release.yml
run: |
yq -i '
(.jobs[].steps[] |
select(.uses == "${{ github.repository }}/.github/actions/install-languages-cli@main") |
.uses
) = "${{ github.repository }}/.github/actions/install-languages-cli@v${{ steps.metadata.outputs.version }}"
' .github/workflows/_buildpacks-release.yml
- name: Create a release tag with required changes
id: release-tag
run: |
git add .
git commit -m "Release v${{ steps.metadata.outputs.version }}"
git tag v${{ steps.metadata.outputs.version }}
git push origin refs/tags/v${{ steps.metadata.outputs.version }}
git tag -f latest
git push -f origin refs/tags/latest
echo "sha=$(git rev-list -n 1 v${{ steps.metadata.outputs.version }})" >> $GITHUB_OUTPUT
- name: Create release
uses: softprops/[email protected]
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.app_token }}
with:
target_commitish: ${{ steps.release-tag.outputs.sha }}
tag_name: v${{ steps.metadata.outputs.version }}
files: ${{ steps.package-binary.outputs.path }}
fail_on_unmatched_files: true
body: "Full Changelog: https://github.com/${{ github.repository }}/compare/v${{ steps.previous-version.outputs.value }}..v${{ steps.metadata.outputs.version }}"