Skip to content

Commit f66a66e

Browse files
chore: add new release (#61)
* chore: add new release * chore: bump version to 1.0.0 * ci: update release-v2 * chore: replace old release with new one
1 parent de5d59a commit f66a66e

5 files changed

Lines changed: 266 additions & 68 deletions

File tree

.github/workflows/release-old.yml

Lines changed: 190 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,190 @@
1+
name: Release Old
2+
on:
3+
workflow_dispatch:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
env:
9+
BIN_NAME: scopelint
10+
PROJECT_NAME: scopelint
11+
REPO_NAME: ScopeLift/scopelint
12+
13+
jobs:
14+
dist:
15+
name: Dist
16+
runs-on: ${{ matrix.os }}
17+
strategy:
18+
fail-fast: true # Fail other jobs if one fails.
19+
matrix:
20+
build: [x86_64-linux, aarch64-linux, x86_64-macos, x86_64-windows, aarch64-macos]
21+
include:
22+
- build: x86_64-linux
23+
os: ubuntu-20.04
24+
rust: stable
25+
target: x86_64-unknown-linux-gnu
26+
cross: true
27+
- build: aarch64-linux
28+
os: ubuntu-20.04
29+
rust: stable
30+
target: aarch64-unknown-linux-gnu
31+
cross: true
32+
- build: x86_64-macos
33+
os: macos-latest
34+
rust: stable
35+
target: x86_64-apple-darwin
36+
cross: true
37+
- build: x86_64-windows
38+
os: windows-2019
39+
rust: stable
40+
target: x86_64-pc-windows-msvc
41+
cross: true
42+
- build: aarch64-macos
43+
os: macos-latest
44+
rust: stable
45+
target: aarch64-apple-darwin
46+
cross: true
47+
48+
steps:
49+
- name: Checkout sources
50+
uses: actions/checkout@v3
51+
52+
- name: Install ${{ matrix.rust }} toolchain
53+
uses: actions-rs/toolchain@v1
54+
with:
55+
profile: minimal
56+
toolchain: ${{ matrix.rust }}
57+
target: ${{ matrix.target }}
58+
override: true
59+
60+
# Currently skipping tests because it fails with:
61+
# thread 'test_check_proj1_all_findings' panicked at 'Failed to execute command: Os { code: 2, kind: NotFound, message: "No such file or directory" }', tests/cli.rs:18:10
62+
# when run here, even though tests work fine in the other actions file.
63+
64+
# # We skip tests for M1 (arm64), because the binary is for M1 but the github runner is Intel,
65+
# # so it can't run the binary/tests. However, the Intel macOS can build the binaries for M1
66+
# # which is what happens here.
67+
# - name: Run cargo test
68+
# uses: actions-rs/cargo@v1
69+
# if: ${{ matrix.build != 'aarch64-macos' }}
70+
# with:
71+
# use-cross: ${{ matrix.cross }}
72+
# command: test
73+
# args: --release --locked --target ${{ matrix.target }}
74+
75+
- name: Build release binary
76+
uses: actions-rs/cargo@v1
77+
with:
78+
use-cross: ${{ matrix.cross }}
79+
command: build
80+
args: --release --locked --target ${{ matrix.target }}
81+
82+
- name: Strip release binary (linux and macos)
83+
if: matrix.build == 'x86_64-linux' || matrix.build == 'x86_64-macos'
84+
run: strip "target/${{ matrix.target }}/release/$BIN_NAME"
85+
86+
- name: Strip release binary (arm)
87+
if: matrix.build == 'aarch64-linux'
88+
run: |
89+
docker run --rm -v \
90+
"$PWD/target:/target:Z" \
91+
rustembedded/cross:${{ matrix.target }} \
92+
aarch64-linux-gnu-strip \
93+
/target/${{ matrix.target }}/release/$BIN_NAME
94+
95+
- name: Build archive
96+
shell: bash
97+
run: |
98+
mkdir dist
99+
if [ "${{ matrix.os }}" = "windows-2019" ]; then
100+
cp "target/${{ matrix.target }}/release/$BIN_NAME.exe" "dist/"
101+
else
102+
cp "target/${{ matrix.target }}/release/$BIN_NAME" "dist/"
103+
fi
104+
105+
- uses: actions/upload-artifact@v2.2.4
106+
with:
107+
name: bins-${{ matrix.build }}
108+
path: dist
109+
110+
publish:
111+
name: Publish
112+
needs: [dist]
113+
runs-on: ubuntu-latest
114+
steps:
115+
- name: Checkout sources
116+
uses: actions/checkout@v2
117+
with:
118+
submodules: false
119+
120+
- uses: actions/download-artifact@v2
121+
# with:
122+
# path: dist
123+
# - run: ls -al ./dist
124+
- run: ls -al bins-*
125+
126+
- name: Calculate tag name
127+
run: |
128+
name=dev
129+
if [[ $GITHUB_REF == refs/tags/v* ]]; then
130+
name=${GITHUB_REF:10}
131+
fi
132+
echo ::set-output name=val::$name
133+
echo TAG=$name >> $GITHUB_ENV
134+
id: tagname
135+
136+
- name: Build archive
137+
shell: bash
138+
run: |
139+
set -ex
140+
141+
rm -rf tmp
142+
mkdir tmp
143+
mkdir dist
144+
145+
for dir in bins-* ; do
146+
platform=${dir#"bins-"}
147+
unset exe
148+
if [[ $platform =~ "windows" ]]; then
149+
exe=".exe"
150+
fi
151+
pkgname=$PROJECT_NAME-$platform
152+
mkdir tmp/$pkgname
153+
# cp LICENSE README.md tmp/$pkgname
154+
mv bins-$platform/$BIN_NAME$exe tmp/$pkgname
155+
chmod +x tmp/$pkgname/$BIN_NAME$exe
156+
157+
if [ "$exe" = "" ]; then
158+
tar cJf dist/$pkgname.tar.xz -C tmp $pkgname
159+
else
160+
(cd tmp && 7z a -r ../dist/$pkgname.zip $pkgname)
161+
fi
162+
done
163+
164+
- name: Upload binaries to release
165+
uses: svenstaro/upload-release-action@v2
166+
with:
167+
repo_token: ${{ secrets.GITHUB_TOKEN }}
168+
file: dist/*
169+
file_glob: true
170+
tag: ${{ steps.tagname.outputs.val }}
171+
overwrite: true
172+
173+
- name: Extract version
174+
id: extract-version
175+
run: |
176+
printf "::set-output name=%s::%s\n" tag-name "${GITHUB_REF#refs/tags/}"
177+
178+
# Uncomment this section if you want to release your package to crates.io
179+
# Before publishing, make sure you have filled out the following fields:
180+
# license or license-file, description, homepage, documentation, repository, readme.
181+
# Read more: https://doc.rust-lang.org/cargo/reference/publishing.html
182+
- name: Install ${{ matrix.rust }} toolchain
183+
uses: actions-rs/toolchain@v1
184+
with:
185+
profile: minimal
186+
toolchain: stable
187+
target: ${{ matrix.target }}
188+
- run: cargo publish --token ${CRATES_TOKEN} --allow-dirty
189+
env:
190+
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}

.github/workflows/release.yml

Lines changed: 52 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,18 @@
1+
# Release modern workflow with crates.io Trusted Publishing.
2+
# Use this to test the new flow. On crates.io add Trusted Publisher with workflow filename: release.yml
3+
# Manual only: run from Actions → Release → Run workflow, and select the version tag (e.g. v1.0.0) as the ref.
14
name: Release
25
on:
36
workflow_dispatch:
4-
push:
5-
tags:
6-
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
# Uncomment this to release on tag push
8+
# push:
9+
# tags:
10+
# - 'v[0-9]+.[0-9]+.[0-9]+'
11+
inputs:
12+
tag:
13+
description: 'Release tag (must already exist in the repo, e.g. v1.0.0)'
14+
required: true
15+
type: string
716

817
env:
918
BIN_NAME: scopelint
@@ -15,17 +24,17 @@ jobs:
1524
name: Dist
1625
runs-on: ${{ matrix.os }}
1726
strategy:
18-
fail-fast: true # Fail other jobs if one fails.
27+
fail-fast: true
1928
matrix:
2029
build: [x86_64-linux, aarch64-linux, x86_64-macos, x86_64-windows, aarch64-macos]
2130
include:
2231
- build: x86_64-linux
23-
os: ubuntu-20.04
32+
os: ubuntu-22.04
2433
rust: stable
2534
target: x86_64-unknown-linux-gnu
2635
cross: true
2736
- build: aarch64-linux
28-
os: ubuntu-20.04
37+
os: ubuntu-22.04
2938
rust: stable
3039
target: aarch64-unknown-linux-gnu
3140
cross: true
@@ -47,7 +56,7 @@ jobs:
4756

4857
steps:
4958
- name: Checkout sources
50-
uses: actions/checkout@v3
59+
uses: actions/checkout@v4
5160

5261
- name: Install ${{ matrix.rust }} toolchain
5362
uses: actions-rs/toolchain@v1
@@ -57,21 +66,6 @@ jobs:
5766
target: ${{ matrix.target }}
5867
override: true
5968

60-
# Currently skipping tests because it fails with:
61-
# thread 'test_check_proj1_all_findings' panicked at 'Failed to execute command: Os { code: 2, kind: NotFound, message: "No such file or directory" }', tests/cli.rs:18:10
62-
# when run here, even though tests work fine in the other actions file.
63-
64-
# # We skip tests for M1 (arm64), because the binary is for M1 but the github runner is Intel,
65-
# # so it can't run the binary/tests. However, the Intel macOS can build the binaries for M1
66-
# # which is what happens here.
67-
# - name: Run cargo test
68-
# uses: actions-rs/cargo@v1
69-
# if: ${{ matrix.build != 'aarch64-macos' }}
70-
# with:
71-
# use-cross: ${{ matrix.cross }}
72-
# command: test
73-
# args: --release --locked --target ${{ matrix.target }}
74-
7569
- name: Build release binary
7670
uses: actions-rs/cargo@v1
7771
with:
@@ -102,7 +96,7 @@ jobs:
10296
cp "target/${{ matrix.target }}/release/$BIN_NAME" "dist/"
10397
fi
10498
105-
- uses: actions/upload-artifact@v2.2.4
99+
- uses: actions/upload-artifact@v4
106100
with:
107101
name: bins-${{ matrix.build }}
108102
path: dist
@@ -111,54 +105,54 @@ jobs:
111105
name: Publish
112106
needs: [dist]
113107
runs-on: ubuntu-latest
108+
permissions:
109+
contents: write # Required to create releases and upload assets
110+
id-token: write # Required for crates.io Trusted Publishing (OIDC)
114111
steps:
115112
- name: Checkout sources
116-
uses: actions/checkout@v2
113+
uses: actions/checkout@v4
117114
with:
118115
submodules: false
119116

120-
- uses: actions/download-artifact@v2
121-
# with:
122-
# path: dist
123-
# - run: ls -al ./dist
117+
- uses: actions/download-artifact@v4
118+
with:
119+
pattern: 'bins-*'
120+
merge-multiple: false
124121
- run: ls -al bins-*
125122

126123
- name: Calculate tag name
127124
run: |
128125
name=dev
129-
if [[ $GITHUB_REF == refs/tags/v* ]]; then
130-
name=${GITHUB_REF:10}
126+
if [[ -z "$name" || "$name" != v* ]]; then
127+
echo "::error::Release tag must be set and start with 'v' (e.g. v1.0.0)"
128+
exit 1
131129
fi
132-
echo ::set-output name=val::$name
130+
echo "val=$name" >> $GITHUB_OUTPUT
133131
echo TAG=$name >> $GITHUB_ENV
134132
id: tagname
135133

136134
- name: Build archive
137135
shell: bash
138136
run: |
139137
set -ex
140-
141138
rm -rf tmp
142139
mkdir tmp
143140
mkdir dist
144-
145141
for dir in bins-* ; do
146-
platform=${dir#"bins-"}
147-
unset exe
148-
if [[ $platform =~ "windows" ]]; then
149-
exe=".exe"
150-
fi
151-
pkgname=$PROJECT_NAME-$platform
152-
mkdir tmp/$pkgname
153-
# cp LICENSE README.md tmp/$pkgname
154-
mv bins-$platform/$BIN_NAME$exe tmp/$pkgname
155-
chmod +x tmp/$pkgname/$BIN_NAME$exe
156-
157-
if [ "$exe" = "" ]; then
158-
tar cJf dist/$pkgname.tar.xz -C tmp $pkgname
159-
else
160-
(cd tmp && 7z a -r ../dist/$pkgname.zip $pkgname)
161-
fi
142+
platform=${dir#"bins-"}
143+
unset exe
144+
if [[ $platform =~ "windows" ]]; then
145+
exe=".exe"
146+
fi
147+
pkgname=$PROJECT_NAME-$platform
148+
mkdir tmp/$pkgname
149+
mv bins-$platform/$BIN_NAME$exe tmp/$pkgname
150+
chmod +x tmp/$pkgname/$BIN_NAME$exe
151+
if [ "$exe" = "" ]; then
152+
tar cJf dist/$pkgname.tar.xz -C tmp $pkgname
153+
else
154+
(cd tmp && 7z a -r ../dist/$pkgname.zip $pkgname)
155+
fi
162156
done
163157
164158
- name: Upload binaries to release
@@ -170,21 +164,14 @@ jobs:
170164
tag: ${{ steps.tagname.outputs.val }}
171165
overwrite: true
172166

173-
- name: Extract version
174-
id: extract-version
175-
run: |
176-
printf "::set-output name=%s::%s\n" tag-name "${GITHUB_REF#refs/tags/}"
167+
- name: Authenticate with crates.io
168+
id: auth
169+
uses: rust-lang/crates-io-auth-action@v1
177170

178-
# Uncomment this section if you want to release your package to crates.io
179-
# Before publishing, make sure you have filled out the following fields:
180-
# license or license-file, description, homepage, documentation, repository, readme.
181-
# Read more: https://doc.rust-lang.org/cargo/reference/publishing.html
182-
- name: Install ${{ matrix.rust }} toolchain
183-
uses: actions-rs/toolchain@v1
184-
with:
185-
profile: minimal
186-
toolchain: stable
187-
target: ${{ matrix.target }}
188-
- run: cargo publish --token ${CRATES_TOKEN} --allow-dirty
171+
- name: Install Rust toolchain
172+
uses: dtolnay/rust-toolchain@stable
173+
174+
- name: Publish to crates.io
175+
run: cargo publish --allow-dirty
189176
env:
190-
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
177+
CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)